[R] Ordering the levels of a vector

Judith Flores juryef at yahoo.com
Mon Dec 3 22:21:09 CET 2007


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



More information about the R-help mailing list