title: creating multiple objects with for loop in R
body: <p>I have a loop that creates multiple plots with ggplot. I would like to create a new object with each plot in the same loop, but I can't find a way.
  This is an example code:</p>
  <pre><code>for(i in 1:5){
     ggplot(df[location==i], aes(x = date, y = value, group = 1)) +
     geom_line()
  }
  </code></pre>
  <p>And I'm trying to do something like this</p>
  <pre><code>for(i in 1:5){
     plot_i -&gt; ggplot(df[location==i], aes(x = date, y = value, group = 1)) +
     geom_line()
  }
  </code></pre>
  <p>To get five objects, plot_1, plot_2, plot_3, and plot_5, in order to be able to call them by the object name later.
  But putting the i from the loop in the object name does not work, it only creates one object: plot_i, which ends up being the last of the sequence (i=5)</p>
  <p>I would be very thankful for any help.</p>