[R] Ordering the levels of a vector

Gabor Grothendieck ggrothendieck at gmail.com
Mon Dec 3 22:36:38 CET 2007


Try mixedsort in the gtools package.

On Dec 3, 2007 4:21 PM, Judith Flores <juryef at yahoo.com> wrote:
> Hi,
>
>   I have a vector in a data frame that looks
> something like this:
>
> day<-c('Day -1','Day 6','Day 10')
>
>
>   This vector specifies the order in which several
> panel will appear in a lattice plots. But the order in
> which such plots will appear will be the following:
> Day -1, Day 10, Day 6. Which makes sense, but I cannot
> name the Days like this: Day -01,Day 10, Day 06, which
> would put the levels in the order I want them to be.
>
>  Now, this vector won't always have the same values,
> it could be:
>
> day<-c('Day -1, 'Day 2','Day 14')
>
>   So I cannot set the levels manually:
>
> levels(day)<-c('Day -1', 'Day something','Day
> something else')
>  I tried as.ordered, but I guess I am not using the
> right function.
>
> How can I command the script to put the panels in the
> original  order given of the vector in a data frame?
>
> Thank  you,
>
> Judith
>
>
>
>
>
>
>
>
>      ____________________________________________________________________________________
> Be a better friend, newshound, and
>
> ______________________________________________
> 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.
>



More information about the R-help mailing list