Hi guys,
 
I ran into a problem of not being able to create unique labels when creating a 
factor. Consider an example below:
 
 hb <- factor(c(1,1,1,2,2,2,3,3,3), levels=c(1,2,3),labels=c(1,1,2))
> hb
[1] 1 1 1 1 1 1 2 2 2
Levels: 1 1 2
> unique(hb)
[1] 1 1 2
Levels: 1 1 2
 
How come there are three unique levels, I thought this would only create one 
unique level?

> unique(as.ordered(hb))
[1] 1 2
Levels: 1 < 1 < 2
 
Is as.ordered the only solution?
 
Thanks in advance,
Greg
 

__________________________________________________



        [[alternative HTML version deleted]]

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to