[R] Superimposing y-variables in Lattice formulas

Stavros Macrakis macrakis at alum.mit.edu
Sat Nov 15 18:34:28 CET 2008


On Fri, Nov 14, 2008 at 6:55 PM, Deepayan Sarkar
<deepayan.sarkar at gmail.com> wrote:
>> ...But how do I specify that I want to display all the Subjects on a... single graph, superimposing them all?
>
> Have you tried
> xyplot ( conc ~ time , Indometh, groups = Subject ) ?

Thanks very much for your help!  That works beautifully.

Any particular reason this can't be specified in the formula?  For a
small number of levels, you can write

    xyplot( ifelse(Subject==1,conc,NA) + ifelse(Subject==2,conc,NA) ~ time, ...)

but obviously that doesn't generalize.  I'd have thought that
something like conc*Subject or (conc | Subject) should mean the same
thing, but these aren't allowed for some reason. But I don't know what
the semantics of the formula operators are.  Neither the 'formula' nor
the 'logic' man page even defines `|`, and the 'xyplot' man page only
gives examples, not a definition of the general case: "the formula is
generally of the form... can also be supplied as ... a special case is
...".

Thanks,

           -s



More information about the R-help mailing list