Skip to content
Prev 198808 / 398506 Next

Using processed objects as arguments of a function

On 11/02/2009 05:04 PM, Steven Kang wrote:
Hi Steven,
There is probably a neater way to construct the list of dataframes, but 
this will probably do what you want:

dnames<-paste("fund",1:nfunds,sep="")
makelist<-function(x) {
  nitems<-length(x)
  newlist<-vector("list",nitems)
  for(item in 1:nitems) newlist[[item]]<-get(x[item])
  return(newlist)
}
dflist<-makelist(dfnames)
do.call("rbind",dflist)

Of course all of the dataframes must have the same number of columns or 
the result will be messy or not there at all.

Jim