i'm trying to export a list of ggplot item into a single .pdf. I've been looking for tips here in SO, but ALL the solutions found didn't worked for me. All i can get are outputs with .pdf that cannot be opened, or results with no pages.
Could anyone give me advice on this?
here is my code example:
p <- lapply(x, fun)
#and i tried
library(gridExtra)
pdf("plots.pdf", onefile = TRUE)
for (i in seq(length(p))) {
do.call("grid.arrange", p[[i]])
}
dev.off()
#and this
GG_save_pdf = function(list, filename) {
#start pdf
pdf(filename)
#loop
for (p in list) {
print(p)
}
#end pdf
dev.off()
invisible(NULL)
}
#and this too
library(ggplot2)
pdf("allplots.pdf",onefile = TRUE)
for(i in glist){
tplot <- ggplot(df, aes(x = as.factor(class), y = value))
print(tplot)
}
dev.off()
Can anyone give me guidance? I think it's not a problem of code itself, rather my understanding on what is going on with the code.
