[R] keeping original order in factor()

Andrew Yee yee at post.harvard.edu
Wed Jun 18 06:22:06 CEST 2008


Apologies for the naieveness of this question, but I'm having trouble
figuring out to have factor() maintain original ordering.

For example,

foo <- c("b","b","a","a")
levels(factor(foo, ordered=T)) #I'd like this to return as "b" "a"
                                          #not "a" "b"

I thought having ordered=T would do the trick.

Thanks,
Andrew



More information about the R-help mailing list