Skip to content
Prev 32483 / 398502 Next

vectorizing data.frame()

That's a misleading title!

You want a single vector by concatenating vectors and recording their
origins.  There's no need for a data frame, and you are certainly not 
`vectorizing data.frame()'.  I presume you want to do this for a list of 
vectors.  How about

use <- c("foo", "bar")
names(use) <- use
xx <- unlist(lapply(use, get))
names(xx) <- sub("[0-9]+$", "", names(xx))
data.frame(names=names(xx), value=xx)

?

That will work with any character vector of names of vectors not ending in 
a digit.
On Mon, 26 May 2003, Robin Hankin wrote: