[R] Line plots in base graphics
Ben Bolker
bbolker at gmail.com
Thu Apr 14 00:27:02 CEST 2011
Hadley Wickham <hadley <at> rice.edu> writes:
> On Wed, Apr 13, 2011 at 2:58 PM, Ben Bolker <bbolker <at> gmail.com> wrote:
> > Hadley Wickham <hadley <at> rice.edu> writes:
> >
> >>
> >> Am I missing something obvious on how to draw multi-line plots in
> >> base graphics?
[snip]
> >> But in base graphics, the best I can come up with is this:
> >>
> > with(Oxboys, plot(age, height, type = "n"))
> > lapply(split(Oxboys[c("age", "height")], Oxboys$Subject), lines)
> >
> > [quoting removed to fool gmane]
> >> Am I missing something obvious?
> >
> > reshape to wide format and matplot()?
>
> Hmmm, that doesn't work if your measurements are at different times e.g:
>
> Oxboys2 <- transform(Oxboys, age = age + runif(234))
In that case I think you're stuck with your lapply() approach,
or (I think) using lattice graphics with the group= argument
(that's not base though).
Ben
More information about the R-help
mailing list