Hi, You could also use ?colwise() from library(plyr) set.seed(50) dat1<-data.frame(Col1=sample(1:20,10,replace=TRUE),Col2=sample(LETTERS[1:10],10,replace=TRUE),Col3=sample(LETTERS[11:20],10,replace=TRUE),Col4=sample(40:60,10,replace=TRUE)) dat1[unlist(colwise(is.factor)(dat1))] # Col2 Col3 #1 D Q #2 C L #3 G R #4 A S #5 C N #6 G Q #7 I P #8 D M #9 A N #10 B N dat1[unlist(colwise(is.numeric)(dat1))] A.K.
----- Original Message ----- From: Martin Spindler <martin.spind...@gmx.de> To: R-help@r-project.org Cc: Sent: Monday, December 17, 2012 5:02 AM Subject: [R] Splitting up of a dataframe according to the type of variables Dear R users, I have a dataframe which consists of variables of type numeric and factor. What is the easiest way to split up the dataframe to two dataframe which contain all variables of the type numeric resp. factors? Thank you very much for your efforts in advance! Best, Martin ______________________________________________ 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.