Re: [R] function returns R object with name based on input

2009-04-26 Thread Jennifer Brea
Thanks for your replies. I ended up using the following: df = data.frame(year =c(1991,1991,1992,1992,1993,1993,1992,1991),x=rnorm(8),y=rnorm(8)) df year x y 1 1991 0.5565083 -1.31364232 2 1991 0.1686598 -0.20344656 3 1992 -0.1010090 -0.65681852 4 1992 0.6130324 -0.107

Re: [R] function returns R object with name based on input

2009-04-24 Thread David Winsemius
On Apr 24, 2009, at 11:56 AM, Jennifer Brea wrote: I wanted to ask how I can make a for loop or a function return an R object with a unique name based on either some XX of the for loop or some input for the function. For example if I have a function: fn<-function(data,year){ which does

[R] function returns R object with name based on input

2009-04-24 Thread Jennifer Brea
I wanted to ask how I can make a for loop or a function return an R object with a unique name based on either some XX of the for loop or some input for the function. For example if I have a function: fn<-function(data,year){ which does does some stuff } How do I return an object from the fu