[R] xyplot() with segments() superposed?

Deepayan Sarkar deepayan.sarkar at gmail.com
Mon Aug 13 21:08:20 CEST 2007


On 8/13/07, Yuelin Li <liy12 at mskcc.org> wrote:
> Thanks for the quick response.  The general use is like the following.
> Suppose I have another variable, tkmark, which for cohort "1970" is
> coded 1.0 at x = c(7, 19) and 0 otherwise.  For cohort "1980", tkmark
> is coded 1.0 at x = c(2, 11, 12, 19) and 0 otherwise.  For each
> "cohort", I want to mark with a short vertical bar the observed Y at
> (x[tkmark == 1 & source == "obs"], y[tkmark == 1 & source == "obs"]).
> I may have up to 65 different "cohorts".  Different cohorts have
> different numbers of tkmark positions (some have none).
>
> The real data come from a computerized cigarette smoking reduction
> program.  I want to plot each smoker's tapering of cigarettes (y) over
> days (x), and mark the quit attempts.  Some participants try to quit
> on days 3, 7, and 17 but resume smoking the next day, some follow the
> programmed tapering exactly with no interim quit attempts, and some
> ignored the tapering program.  I want to plot each participant's
> **scheduled** and **observed** smoking pattern over days and mark the
> quit attempts.  Hope this is clear.

Sounds like you need to pass your 'tkmarks' variable on to the panel
function and then use 'subscripts' inside your panel function. Read
the entry on 'panel' in ?xyplot. Also, there's a fairly long thread on
a similar problem which you might find useful. It starts with

https://stat.ethz.ch/pipermail/r-help/2007-July/136188.html

-Deepayan



More information about the R-help mailing list