title: Way save as png in R with plot title?
body: <p>I am trying to create a for loop that allows me to generate violin plots for my data set and then save said violin plot as a .png where the name of the png file is the main title of the plot.png.</p>
  <p>For example using the iris data set if the violin plot made was looking at Petal.width ~ Petal.length in virginica, setose, and verascolor I would like the saved pngs to be named virginica.png, setose.png, and verascolor.png</p>
  <p>Here is the code used for my plot using the iris data set.</p>
  <pre><code>for(i in 1:3){
    #png(file=paste(,&quot;.png&quot;))
    print(iris %&gt;% group_by(Species) %&gt;% 
            ggplot(aes(x=Petal.Width,y=Petal.Length)) +
            geom_violin(aes()) +
            geom_jitter(aes(colour = Petal.Length), width = 0.2) +
            theme_classic2()+
            theme(strip.background = element_rect(colour = &quot;white&quot;, fill = &quot;white&quot;), 
                  strip.text = element_text(size = 18), 
                  legend.position = &quot;none&quot;,
                  axis.title.x = element_text(colour = &quot;white&quot;))+
            stat_compare_means( label = &quot;p.signif&quot;, label.x = 1.5,) +
            facet_wrap_paginate(~Species,ncol =1, nrow=1, scales = &quot;free&quot;, page = i))
    
  } 
  
  
  #I tried using this line of code to work around the problem, but for some reason the
  #plots for my data set are not always processed in the same order so using a list did not work. 
  
  png(file=paste(file=file[[i]],&quot;.png&quot;))
  </code></pre>