Reputation: 241
in a similar situation as presented in this question, I am outputting multiple timeseries charts from a single dataframe, and I can not figure out to add the unique chart title to each plot....
my data can be found here
and I am approaching this as follows
gw <- read.csv("gw_cbp.csv")
require(ggplot2)
require(plyr)
require(gridExtra)
pl <- dlply(gw, .(Well.ID), function(dat) {
ggplot(data = dat, aes(group = 1, x = Date, y = Benzene), ) + geom_line() +
geom_point() + xlab("Date") + ylab("mg/Kg") +
geom_smooth(method = "lm") + ggtitle(Well.ID)
})
ml <- do.call(marrangeGrob, c(pl, list(nrow = 32, ncol = 1)))
ggsave("benzene.pdf", ml, height = 72, width = 11, units = "in", limitsize = F)
here the
+ ggtitle(Well.ID)
is not finding the individual Well.ID's being used in the ddply function...
can anyone show me how to call the unique Well.ID's for this situation?
thanks ZR
Upvotes: 1
Views: 603
Reputation: 206546
Try
+ ggtitle(dat$Well.ID)
The parameters for ggtitle
are not evaulated in the context of the data.frame you pass to ggplot()
so you need to be explicit about where that value is coming from.
Upvotes: 2