title: Display and save the plot simultaneously in R, RStudio
body: <p>I need to save the plot as .png and show the plot at the same time without duplicating the code.
  Is there an elegant way to do it?
   Working on RStudio for MAC.</p>
  
  <p>I can get it to work as bellow but I don't like it.</p>
  
  <pre><code>#Step1: save the plot
  png("myplot.png")
  #plot code
  dev.off()
  
  #Step2: to display the plot
  #plot code (again!) to display it in RStudio
  </code></pre>
  
  <p>Cheers,
  I.M.</p>