Re: [R] how to use do.call together with cbind and get inside a function

2009-07-26 Thread Gabor Grothendieck
Use lapply(ColNameVec, get, environment()) so that it gets the objects from the current environment. See: ?get ?environment On Sun, Jul 26, 2009 at 11:16 PM, Sean Zhang wrote: > Dear R-helpers: > I have a question related to using do.call to call cbind and get. > > #the following works > vec1 <- c

[R] how to use do.call together with cbind and get inside a function

2009-07-26 Thread Sean Zhang
Dear R-helpers: I have a question related to using do.call to call cbind and get. #the following works vec1 <- c(1,2) vec2 <- c(3,4) ColNameVec <- c('vec1','vec2') mat <- do.call("cbind",lapply(ColNameVec,get)) mat #put code above into a function then it does not work #before doing so, first remo