[R] Create a function with multiple object as an output

Arnaud Mosnier a.mosnier at gmail.com
Wed Feb 10 14:31:48 CET 2010


Dear useRs,

I want to make a function that return several object (from a loop).
I know, I can put them in a list, then the function return  the list,
but is it possible that it returns several independent object.
I used the assign function to create several object, it works when I
use it outside the function, but not inside.

Any suggestion ?

Here is a piece of code that do something similar to my situation.

testfunc <- function ( listobj, valueX) {
        for (i in 1:length(listobj)) {
             objtemp <- get (listobj[i])
             objtemp <- objtemp * valueX
             assign(paste(listobj[i], "_", valueX, sep=""), objtemp)
        }
return (??????????????????????)
}



More information about the R-help mailing list