[R] Sorting

Henrique Dallazuanna wwwhsd at gmail.com
Wed Sep 23 14:08:07 CEST 2009


Try this:

DF$Category <- factor(DF$Category, levels = c("b", "a"))

On Wed, Sep 23, 2009 at 4:16 AM, Chris Li <chrisli at austwaterenv.com.au> wrote:
>
> Hello,
>
> Say I have a dataset as followed:
>
> Category     Value
> b                1
> b                2
> a                7
> a                1
>
> Then, if I:
>
> levels(Category)
>
> It will return:
> [a], [b]
>
> But I want to keep the original order, i.e.:
> [b], [a]
>
> Is it possible to do it in R?
>
> Thanks in advance!
>
> Chris
> --
> View this message in context: http://www.nabble.com/Sorting-tp25531007p25531007.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O




More information about the R-help mailing list