[R] ordering of levels.

Wolski wolski at molgen.mpg.de
Mon Jul 26 20:48:05 CEST 2004


Hi!
Have the following factors with the following levels.
 tmp$norm
 [1] rank rank rank rank rank log  log  log  rank sqrt sqrt sqrt log  log  rank
[16] rank rank sqrt sqrt sqrt sqrt log  log  log  log  sqrt none none none none
[31] none none none none sqrt none
Levels: log none rank sqrt

I would like to add an ordering to the levels.
none<sqrt<log<rank

I tried with 
tmp$norm <-factor(tmp$norm,labels = c("none","sqrt","log","rank"),ordered=T)
>tmp$norm
 [1] log  log  log  log  log  none none none log  rank rank rank none none log 
[16] log  log  rank rank rank rank none none none none rank sqrt sqrt sqrt sqrt
[31] sqrt sqrt sqrt sqrt rank sqrt
Levels: none < sqrt < log < rank

But this is not what I would like to have because the command not only superimposes an ordering but also changes the factors!

Eryk




More information about the R-help mailing list