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

2009-10-12 Thread Stropharia
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) } # -

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

2009-10-12 Thread Tony Plate
test$x doesn't evaluate the function, you want something like test(1,2)$x, e.g.: test <- function(i, j){ x <- i:j y <- i*j z <- i/j return(list(x=x,y=y,z=z)) } test(1,2)$x [1] 1 2 test(1,2)$y [1] 2 test(1,2)$z [1] 0.5 Or if you want to avoid evaluating y

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

2009-10-12 Thread Daniel Nordlund
> -Original Message- > From: r-help-boun...@r-project.org > [mailto:r-help-boun...@r-project.org] On Behalf Of Stropharia > Sent: Monday, October 12, 2009 4:07 PM > To: r-help@r-project.org > Subject: [R] Re use objects from within a custom made function > >

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

2009-10-12 Thread Stropharia
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 <- functi

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

2009-10-12 Thread David Winsemius
On Oct 12, 2009, at 7:06 PM, 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