Re: [R] Ordering the levels of a vector

From: Gabor Grothendieck <ggrothendieck_at_gmail.com>
Date: Mon, 3 Dec 2007 16:36:38 -0500

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.
>



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. Received on Mon 03 Dec 2007 - 21:41:36 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 03 Dec 2007 - 22:30:16 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.