RE: [R] getting values out of functions

From: Liaw, Andy <andy_liaw_at_merck.com>
Date: Fri 30 Jul 2004 - 11:21:05 EST


> From: Kathryn Jones
>
> Hi there,
> Just wondering if there's a way to get a value you've
> assigned within a function, out of the function?
> For example,
>
> function ()
> {
> testing <-read.table("...",header=TRUE)
> }
>
> I want to be able to use 'testing' outside of the function,
> so be able to call ls() and testing be there...
> Any ideas?
> Thanks!
> Kathryn

Sure, by return()ing it in the last line of the function.

Alternatively, you can assign() to .GlobalEnv, but you really should avoid doing that...

Andy



R-help@stat.math.ethz.ch mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Fri Jul 30 11:26:28 2004

This archive was generated by hypermail 2.1.8 : Wed 03 Nov 2004 - 22:55:22 EST