Hi, I have a dataframe with around 100 columns. Now I want to redefine some of the columns as factors (using as.factor). Luckily all the names of the columns I want to redefine start with "crast". Thus I thought I can use grep() for that purpose... ...I found an example for redefining a single column as factor but that is not working with multiple columns I get from grep()...
what I tried so far: df[, grep("^crast", colnames(df))] <- as.factor(df[, grep("^crast", colnames(df))]) any suggestions? cheers, /Johannes -- Jetzt informieren: http://mobile.1und1.de/?ac=OM.PW.PW003K20328T7073a ______________________________________________ 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.