Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Create data frame from variable number of vectors (See related posts)

// Create a data frame from a varied number of vectors
// Taken from http://article.gmane.org/gmane.comp.lang.r.general/56501/match=create+data+frame

N1 <-c(1,2,3,4)
N2 <-c(1,2,3,4)
N3 <-c(1,2,3,4)
abc <-c(1,2,3)
lab <- paste("N", seq(along=abc), sep="")
D <- data.frame(lapply(lab, get))
names(D) <- lab

You need to create an account or log in to post comments to this site.


Click here to browse all 4861 code snippets

Related Posts