In R, for a function whose input is one variable and output is a list, how can I apply the function to a list of inputs and combine the output lists into one data frame or matrix?
For example:
fun = function(x){
list = c(x, x+1, x+2)
return(list)
}
Now I'd like to apply fun() to a list, say
list = c(1,11,21)
The result should be
1,2,3
11,12,13
21,22,23
I know do.call and loop will do it. But is there a better way of doing it, perhaps without looping? The actual function is too big and too slow, I would rather not looping it.