[R] Line plots in base graphics

Hadley Wickham hadley at rice.edu
Wed Apr 13 21:51:53 CEST 2011

Am I missing something obvious on how to draw multi-line plots in base graphics?

In ggplot2, I can do:

data(Oxboys, package = "nlme")

qplot(age, height, data = Oxboys, geom = "line", group = Subject)

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)

Am I missing something obvious?



Assistant Professor / Dobelman Family Junior Chair
Department of Statistics / Rice University

More information about the R-help mailing list