[R] getting values out of functions

Roger D. Peng rpeng at jhsph.edu
Fri Jul 30 03:24:39 CEST 2004


You can use assign(), but why do you want to do this?  Also, a function 
always returns the last expression in the function body.  Or you can use 
return().

-roger

Kathryn Jones wrote:

> 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
> 
> ______________________________________________
> R-help at 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
>




More information about the R-help mailing list