Skip to content
Prev 313742 / 398513 Next

Splitting up of a dataframe according to the type of variables

f<-factor(c(1,1,2,3))
n<-c(1,1,2,3)
df<-data.frame(f,n)

sapply(df,is.factor)
f     n 
TRUE FALSE 
df[sapply(df,is.factor)]
f
1 1
2 1
3 2
4 3

 df[sapply(df,is.numeric)]
  n
1 1
2 1
3 2
4 3

something like that?
On 17.12.2012, at 11:02, Martin Spindler wrote: