title: ggplot2 error: geom_line requires the following missing aesthetics: y
body: <p>I am trying to plot several line graphs from a list using a loop in R. The list <code>temp.list</code> looks like this:</p>
  
  <pre><code>&gt; temp.list[1]
  $`1`
    NEW_UPC       Week1 Week2 Week3 Week4 Week5 Week6 Week7 Week8 Week9 Week10 Week11 Week12
  5 11410008398     3     6    11    15    15    27    31    33    34     34     34     34
    Life Status Num_markets    Sales
  5  197      1          50 186048.1
  </code></pre>
  
  <p>I use only some part of the data above to plot, specifically items 2 to 13 in the list will go on the y-axis, i.e. 3,6,11,15,...,34. For x-axis, I would like to have Week 1, Week 2, ..., Week 12 at the tick marks. As I don't know how to assign character values to x in gglplot command, I created a variable called <code>weeks</code> for x-axis as below:</p>
  
  <pre><code>weeks = c(1,2,3,4,5,6,7,8,9,10,11,12)
  </code></pre>
  
  <p>The code that I used to generate the plot is below:</p>
  
  <pre><code>for (i in 1:2) {
    markets= temp.list[[i]][2:13]
    ggplot(data = NULL,aes(x=weeks,y=markets))+geom_line()+
      scale_x_continuous(breaks = seq(0,12,1))+
      scale_y_continuous(breaks = seq(0,50,5))
  }
  </code></pre>
  
  <p>This code does not generate any plot. When I run just the below lines:</p>
  
  <pre><code>ggplot(data = NULL,aes(x=weeks,y=markets))+geom_line()+
      scale_x_continuous(breaks = seq(0,12,1))+
      scale_y_continuous(breaks = seq(0,50,5))
  </code></pre>
  
  <p>I get this error:</p>
  
  <pre><code>Error: geom_line requires the following missing aesthetics: y
  In addition: Warning message:
  In (function (..., row.names = NULL, check.rows = FALSE, check.names = TRUE,  :
    row names were found from a short variable and have been discarded
  </code></pre>
  
  <p>Any help to fix this will be appreciated. I looked at some related discussions <a href="https://stackoverflow.com/questions/29459866/ggplot2-error-geom-point-requires-the-following-missing-aesthetics-y">here</a>, but I am not clear how to proceed.</p>
  
  <p>Also, any better way to generate multiple plots is also welcome. From <code>temp.list</code>, I am looking to generate over 300 separate line graphs (i.e, not all lines in one chart).</p>