Re: [R] Extracting factor columns from a data frame

2008-04-24 Thread Henrique Dallazuanna
Try this: dat <- data.frame(x = gl(4, 5), y = gl(5, 4), z = rnorm(20)) res <- dat[sapply(dat, is.factor)] On Thu, Apr 24, 2008 at 9:14 AM, Serge Merzliakov <[EMAIL PROTECTED]> wrote: > Hi All, >I have attempted to extract only the factor columns from an > existing data set inside a loop wi

[R] Extracting factor columns from a data frame

2008-04-24 Thread Serge Merzliakov
Hi All, I have attempted to extract only the factor columns from an existing data set inside a loop without success . I tried the transform function which worked, but not inside the loop (attempts with cbind did not work either - inside a loop). Here is my function: getcatcolumns<-function