Hi Jeff, jrdf<-data.frame(A=rnorm(10),B=rnorm(10),C=rnorm(10), D=rnorm(10),E=rnorm(10),F=rnorm(10),G=rnorm(10), H=rnorm(10),I=rnorm(10),J=rnorm(10)) for(i in c(2,7,8,9)) jrdf[,i]<-factor(jrdf[,i]) sapply(jrdf,"class")
Jim On Tue, Jun 12, 2018 at 9:57 AM, Jeff Reichman <reichm...@sbcglobal.net> wrote: > R-Help Forum > > > > If I have a data frame consisting of say ten (10) variables > (A,B,C,D,E,F,G,H,I,J) and I want to change Variables 2,7,8,and 9 to factors > is there a command such that I can do it in one line or do I simply have to > convert each separately? > > > > Jeff > > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > 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 -- To UNSUBSCRIBE and more, see 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.