Skip to content
Prev 284731 / 398502 Next

factor level for non-existing value

Hi
you can do it when constructing a factor

a<-factor(c(2,3,3,2,4,2,3,2,2,2,3,2,3), levels=1:4,labels=c("dislike very 
much","dislike","like","like very much"))

or when you already have a factor

a<-factor(a, levels=1:4)

I basically understand that factor is a vector of numeric values with 
levels and labels attribute. Each level can have some label which can be 
changed independently. All levels does not need to be present in a factor.

However you shall not confuse it with function ?labels which has nothing 
to do with factors.

Regards
Petr
http://www.R-project.org/posting-guide.html