title: ggplot for loop problems
body: <p>I am trying to create ggplots based on a unique variable by using a for loop, and experiencing the following issues:
  * This is a large data set (for my processing power, at least) of tree measurements, so I have subset them to make things a bit easier...
  * I am happy to use baseplot if that is easier, they dont have to be pretty!</p>
  
  <ol>
  <li><p>When I run the script on the smaller set, the plots are printed to pdf, but they repeat for the number of times that each unique/for variable occurs in the dataset (10-30 reps).</p></li>
  <li><p>When I run the same script on a larger subset (only difference is the df name), i get the following:</p></li>
  </ol>
  
  <p>geom_path: Each group consists of only one observation. Do you need to adjust the group aesthetic?
  * I have tried aes(group = 1) and changing the variable types, with no luck...</p>
  
  <p>Script and tibble below:</p>
  
  <h1>Attempt a unique loop print to pdf</h1>
  
  <pre><code>p &lt;- list()
  for(i in 1:length(Egra$Unique_Tree_Code)) {
    p[[i]] &lt;- list()
    data &lt;- subset(Egra, Unique_Tree_Code == Unique_Tree_Code[i])
    p[[i]][[1]] &lt;- ggplot(data, aes(RelHt,RelDOB)) + geom_line() +
      ggtitle(data$Unique_Tree_Code) + xlim(0, 1) + ylim(0 , 1.25)
    }
  
  
  library(gridExtra)
  
  pdf("plots.pdf", onefile = TRUE)
  for (i in seq(length(p))) {
    do.call("grid.arrange", p[[i]])  
  }
  dev.off()
  </code></pre>
  
  <h1>DF1</h1>
  
  <pre><code># A tibble: 851 x 4
      RelHt RelDOB RelDIB Unique_Tree_Code 
      &lt;dbl&gt;  &lt;dbl&gt;  &lt;dbl&gt; &lt;chr&gt;            
   1 0.0170  1.06   0.944 100 B05a 11 1 233
   2 0.0341  1.04   0.871 100 B05a 11 1 233
   3 0.0568  1.03   0.863 100 B05a 11 1 233
   4 0.0739  0.996  0.854 100 B05a 11 1 233
   5 0.114   0.957  0.841 100 B05a 11 1 233
   6 0.170   0.944  0.820 100 B05a 11 1 233
   7 0.227   0.936  0.811 100 B05a 11 1 233
   8 0.284   0.897  0.803 100 B05a 11 1 233
   9 0.341   0.828  0.730 100 B05a 11 1 233
  10 0.398   0.815  0.721 100 B05a 11 1 233
  # ... with 841 more rows
  </code></pre>
  
  <h1>DF2</h1>
  
  <pre><code># A tibble: 1,772 x 4
      RelHt RelDOB RelDIB Unique_Tree_Code  
      &lt;dbl&gt;  &lt;dbl&gt;  &lt;dbl&gt; &lt;chr&gt;             
   1 0.0113  1.05   1.04  100 A05e 9.8 1 248
   2 0.0226  1.04   0.940 100 A05e 9.8 1 248
   3 0.0376  1.00   0.915 100 A05e 9.8 1 248
   4 0.0489  1      0.899 100 A05e 9.8 1 248
   5 0.0752  0.960  0.863 100 A05e 9.8 1 248
   6 0.113   0.923  0.847 100 A05e 9.8 1 248
   7 0.150   0.911  0.843 100 A05e 9.8 1 248
   8 0.188   0.867  0.827 100 A05e 9.8 1 248
   9 0.226   0.863  0.806 100 A05e 9.8 1 248
  10 0.263   0.859  0.798 100 A05e 9.8 1 248
  # ... with 1,762 more rows
  </code></pre>