Hi, Try this: set.seed(1) df1<-data.frame(col1=rnorm(10,15),col2=rep(c("a","b"),5),col3=sample(1:50,10,replace=TRUE),col4=sample(LETTERS[1:10],10,replace=TRUE))
df2<-do.call(rbind,lapply(df1,function(x) data.frame(x))) str(df2) 'data.frame': 40 obs. of 1 variable: $ x: chr "14.3735461892577" "15.1836433242221" "14.16437138759" "16.5952808021378" ... tail(df2) # x #col4.5 I #col4.6 G #col4.7 H #col4.8 B #col4.9 H #col4.10 E head(df2) # x #col1.1 14.3735461892577 #col1.2 15.1836433242221 #col1.3 14.16437138759 #col1.4 16.5952808021378 #col1.5 15.3295077718154 #col1.6 14.179531615882 A.K. ----- Original Message ----- From: brunosm <brunos...@gmail.com> To: r-help@r-project.org Cc: Sent: Tuesday, October 23, 2012 7:45 AM Subject: [R] Join data frame columns Hi, I have a data frame with 100 variables (numeric and non numeric types), and I want to join them in only one column, like a vector, but i want to keep the non numeric variables like they are. I know that i can do something like this: Suppose that my data is in df variable new_df<-data.frame(c(df[,1],df[,2],df[,3],df[,4],...........) This works but i have 100 variables! Any way of doing this a little bit faster? Thanks a lot! -- View this message in context: http://r.789695.n4.nabble.com/Join-data-frame-columns-tp4647113.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.