This question already has an answer here:
- Save several ggplots to files 2 answers
I have a plot I am trying to save to a PNG for a bunch of different objects in a list of lists. The code looks something like this:
ggsave("image.png", plot = plotscombined, width = 11, height =5)
I want it to so that every object in the list has its own plot with its own name. I thought this would be easy, as I have a list of the objects, and I was going to reference it as such through a loop:
ggsave(list[i].png, plot = plotscombined, width = 11, height =5)
However, I realize this is not an option. So, could anybody explain how this could be done? I know, I know, loops are bad in R when there are vectorized methods, but there's a big chunk of my code that needs a loop, so I would rather find a way without altering a lot of my code.
Thanks!