[R] Re use objects from within a custom made function

Stropharia stevenworthington at hotmail.com
Tue Oct 13 04:01:45 CEST 2009


Thanks a lot Tony and Daniel for making that clear.

best,

Steve



Stropharia wrote:
> 
> Hi everyone,
> 
> i'm having a problem extracting objects out of functions i've created, so
> i can use them for further analysis. Here's a small example:
> 
> # ---------------------------
> test <- function(i, j){
> 	x <- i:j
> 	y <- i*j
> 	z <- i/j
> 	return(x,y,z)
> }
> # ---------------------------
> 
> This returns the 3 objects as $x, $y and $z. I cannot, however, access
> these objects individually by typing for example:
> 
> test$x
> 
> I know i can do this by adding an extra arrow head to the assignment arrow
> (<<-), but I am sure that is not how it is done in some of the established
> R functions (like when calling lm$coef out of the lm function). Is there a
> simple command i've omitted from the function that allows access to
> objects inside it?
> 
> Thanks in advance,
> 
> Steve
> 

-- 
View this message in context: http://www.nabble.com/Reuse-objects-from-within-a-custom-made-function-tp25864695p25866081.html
Sent from the R help mailing list archive at Nabble.com.




More information about the R-help mailing list