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(x)
{
    # ignore type checking for data frames etc
     res <- data.frame()
     for(i in 1:length(x))
     {
        if (class(x[,i]) =="factor") res <- transform(res, colname = 
x[,i])  # append the factor column to the new data frame (res)
     }
   return(res)
}

The error I get is: "arguments imply differing number of rows: 0, 5000"

All help appreciated.
 
Regards,
 Serge Merzliakov

______________________________________________
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.

Reply via email to