ggplot over many data frames changing titles
ggplot2, r
Solution
You could try something like this,
parameters = data.frame(p1=letters[1:5], p2=round(rnorm(5),2))
l = replicate(5, data.frame(x=1:10, y=rnorm(10)), simplify=FALSE)
names(l) = do.call(paste, c(parameters, sep=","))
plot_one = function(x)
ggplot(data = l[[x]]) + geom_path(aes(x, y)) +
opts(title = x)
plots = lapply(names(l), plot_one)
do.call(gridExtra::grid.arrange, plots)
Problem
I have many data frames which are the output of the same kind of analysis but with different parameters. I'd like to plot the data frames with `ggplot`, changing the main title to specify the different parameters used. I thought about putting the data frames into a list and using `lapply`. But I couldn't figure out how to change the title accordingly in `lapply`.