How to save ggplot facets as separate objects and files

Viewed 43

I want to make similar multiple plots as separate objects in R and save them as separate files. The code i'm using to make the plot is as follows:

P <- ggplot (DF1, aes(fill=TUNNUS, y=PEOPLE, x=FLOW))+
   geom_bar( position="stack", stat="identity")+
   facet_wrap(~group)

This will make 70 different facets as i have 70 groups in my data. I want each group to be it's own plot. This is important as i want them to have different max x-axis values. Also I would like to save them all in different files. Preferably the file name would be the group name, but that is not mandatory. How do i make it happen without needing to make 70 plots and 70 save files?

Thank you,

0 Answers
Related