Re: [R] Superimposing y-variables in Lattice formulas

From: Deepayan Sarkar <deepayan.sarkar_at_gmail.com>
Date: Sat, 15 Nov 2008 11:54:25 -0800

On 11/15/08, Stavros Macrakis <macrakis_at_alum.mit.edu> wrote:
> 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

Mostly historical, but the 'groups' approach makes the design cleaner and more generalizable, although that fact is difficult to appreciate without some experience.

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

There is no general interpretation for a "formula", it is always function-specific. I consider the part of the help page you quoted (without the omissions) a completely general description of the formula as applicable to xyplot():

  " The formula is generally of the form 'y ~ x | g1 * g2 * ...' "

(along with a later paragraph documenting the special interpretation of '+' ).

Note that a help page is intended to describe the capabilities of the function/object it is documenting, not the capabilities that are missing, even though those who have preconceived ideas of how certain things should behave often think that it is somehow the responsibility of the help page to anticipate all such misunderstandings.

If you want a holistic introduction to a suite of tools like lattice, function documentation (which is by definition function-centric) is not the best place to look.

-Deepayan



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 Sat 15 Nov 2008 - 19:56:26 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 17 Nov 2008 - 01:30:26 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.

list of date sections of archive