[R] level assignment

Christian Schulz ozric at web.de
Tue Jun 8 13:09:25 CEST 2004


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

Many thanks for any hint/help
Christian




More information about the R-help mailing list