On Thu, Jun 28, 2012 at 9:27 PM, startend <startend...@gmail.com> wrote:
> Hi,
>
> Now i am dealing with longitudinal data set and I want to see the rough
> marginal plot for 2 variables separately.
> I found the code from one example here,
>
> reading <-
> read.table("http://www.ats.ucla.edu/stat/R/examples/alda/data/reading_pp.txt";,
> header=T, sep=",")
> reading[reading$id %in% c(4, 27, 31, 33, 41, 49, 69, 77, 87), ]
>
> xyplot(piat~age | id
> , data=reading[reading$id %in% c(4, 27, 31, 33, 41, 49, 69, 77, 87),
> ],panel=function(x,y,*subscripts*){
>        panel.xyplot(x, y, pch=16)
>           panel.lmline(x,y, lty=4)
>      panel.xyplot(reading$agegrp*[subscripts]*, y, pch=3)
>      panel.lmline(reading$agegrp*[subscripts]*,y)
> }
> , ylim=c(0, 80), as.table=T, *subscripts*=T)
>
> I just don't know what the subscripts for and the meaning of that.
> Can someone kindly let me know how it works.

See ?xyplot, particularly the entry for 'panel'.

If a lattice plot has one or more conditioning variables ('id' here),
then the data used in each panel is a subset of the full data.
'subscripts' is an optional argument passed to the panel function that
allows you to obtain the association between the original rows of the
data and the data used in the panels. For example, if your data is

 x  y id
 1  1  1
 2  2  2
 3  3  1
 4  4  2
 5  5  1
 6  6  2
 7  7  1
 8  8  2
 9  9  1
10 10  2

and the formula is y ~ x | id, then the first panel (corresponding to
id = 1) will have subscripts=c(1, 3, 5, 7, 9), and the second will
have c(2, 4, 6, 8, 10).

For a more realistic example, see
http://lattice.r-forge.r-project.org/Vignettes/src/lattice-tricks/regression-lines.pdf
(page 12).

-Deepayan

______________________________________________
R-help@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.

Reply via email to