[R] getting values out of functions
Liaw, Andy
andy_liaw at merck.com
Fri Jul 30 03:21:05 CEST 2004
> 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
More information about the R-help
mailing list