Hi Hadley, Thanks for your suggestion.
The description of ggplot states: Description: ... It combines the advantages of both base and lattice graphics ... and you can still build up a plot step by step from multiple data sources So I thought I'd try to enhance the plot by adding in the means from each quarter (this is snagged directly from ESS): > qplot(Quarter, Consumption, data=data, type=c("point","line"), id=data$Year) ( mean.per.quarter<- with(data, tapply(Consumption, Quarter, mean)) ) points(mean.per.quarter, pch="+", cex=2.0) qplot(Quarter, Consumption, data=data, type=c("point","line"), id=data$Year) > ( mean.per.quarter<- with(data, tapply(Consumption, Quarter, mean)) ) 1 2 3 4 888.2 709.2 616.4 832.8 > points(mean.per.quarter, pch="+", cex=2.0) Error in plot.xy(xy.coords(x, y), type = type, ...) : plot.new has not been called yet > > Now I'm green behind the ears when it comes to R, so I'm guessing that there is some major conflict between base graphics and lattice graphics, which I thought ggplot avoided, given the library help blurb. I'm assuming that there must be a way to add points / lines to lattice / ggplot graphics (in the latter case it seems to be via ggpoint, or some such)? But is there a way that allows me to add via: points(mean.per.quarter, pch="+", cex=2.0) and similar, or do I have to learn the lingo for lattice / ggplot? Thanks, Jack. hadley wickham <[EMAIL PROTECTED]> wrote: > And if lattice is ok then try this: > > library(lattice) > xyplot(Consumption ~ Quarter, group = Year, data, type = "o") Or you can use ggplot: install.packages("ggplot") library(ggplot) qplot(Quarter, Consumption, data=data,type=c("point","line"), id=data$Year) Unfortunately this has uncovered a couple of small bugs for me to fix (no automatic legend, and have to specify the data frame explicitly) The slighly more verbose example below shows you what it should look like. data$Year <- factor(data$Year) p <- ggplot(data, aes=list(x=Quarter, y=Consumption, id=Year, colour=Year)) ggline(ggpoint(p), size=2) Regards, Hadley --------------------------------- [[alternative HTML version deleted]] ______________________________________________ R-help@stat.math.ethz.ch 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.