1

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

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks. I had tried (dat) and (Well.ID) separately... i had not thought of binding them.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.