title: Inserting an R variable into a string
body: <p>I'm trying to produce multiple charts and figures using a for loop in R. </p>
  
  <p>I'm writing the files like this:</p>
  
  <pre><code>for(i in 1:10){
  png("C:/Users/Username/Documents/FileName.png", height = 8, width = 14, units = 'in', res = 350)
  g &lt;- ggplot(df)
  dev.off()
  print(g)
  }
  </code></pre>
  
  <p>However, I'm pretty sure if I try to execute this code, I'm going to end up with either 1 "FileName.png" or "FileName.png", "FileName(1).png", etc. Is there a way that I can introduce a variable inside the <code>png()</code> string that would depend on the index? </p>