[R] Reverse order of grouping factor in grouppedData

Deepayan Sarkar deepayan.sarkar at gmail.com
Thu Dec 14 02:02:07 CET 2006


On 12/13/06, RMan54 <RMan54 at cox.net> wrote:
>
> I created the following groupedData object (nlme library):
>
> gd <- groupedData(Conc ~ Time | Subj,
>     order.groups=T,
>     FUN = myf,
>     data=mydata)
>
> The idea of the myf function is to reverse the order of the grouping factor
> Subj (or better, reorder from largest to smallest). In the mydata data set,
> Subj is an integer that gets converted into a factor in the groupedData
> object.
> Does anyone knows how to write this function myf?
>
> It may be even impossible to do it this way because the function is applied
> on the dependent variable Conc (default in the package is mean), while I
> need to apply my stuff on the factor Subj.
>
> The lattice plot routines underneath the nlme library (like xyplot)
> unfortunately start plotting the panels on the bottom of the page and up. In
> order to have the order in a logical fashion (smallest to highest subj
> number starting on top of the page and down), I need to reorder in the
> groupedData object.

Why? Why not consider the more natural solution of reordering while
plotting? The 'as.table' argument of xyplot allows you to order panels
from top to bottom, and arguments to xyplot etc can be passed to
plot(groupedData.obj...) calls directly. If you feel that the default
is "unfortunate", you can even change it globally using

lattice.options(default.args = list(as.table = TRUE))

-Deepayan



More information about the R-help mailing list