On Tue, 8 Jun 2004 13:09:25 +0200 Christian Schulz wrote: > Hi, > > i would like recocde some numeric variables in one > step, but hanging unexpected in a level asignment problem? > > for(i in 2:length(msegmente)) > { msegmente[,i] <- as.factor(msegmente[,i]) > } > > Problem is that not every level is in every variable, so the > asignment is necessary!? > > levels(LT.200301) <- c(1=AK,3=GC,10=OC, > 29=AM,32=IA,38=ACH,52=ZBA,53=A9L,59=EHK) > Error: syntax error > > levels(LT.200301) <- list(c(1=AK,3=GC,10=OC, > 29=AM,32=IA,38=ACH,52=ZBA,53=A9L,59=EHK)) > Error: syntax error > > levels(LT.200301) <- c(1="AK",3="GC",10="OC", > 29="AM",32="IA",38="ACH",52="ZBA",53="A9L",59="EHK") > Error: syntax error
I'm not sure what exactly you are trying to do, but does replacing as.factor(msegmente[,i]) by factor(msegmente[,i], levels = c(1, 3, 10, 29, 32, 38, 52, 53, 59), labels = c("AK","GC","OC","AM","IA","ACH","ZBA","A9L","EHK")) yield the desired result? hth, Z > Many thanks for any hint/help > Christian > > ______________________________________________ > [EMAIL PROTECTED] mailing list > https://www.stat.math.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! > http://www.R-project.org/posting-guide.html > ______________________________________________ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html