title: Drawing multiple line + ribbon plots in ggplot2
body: <p>My data set looks like this</p>
  
  <pre><code>sample_data &lt;- structure(list(chrom = structure(c(1L, 2L, 3L, 4L, 1L, 2L, 3L, 4L), 
                                                  .Label = c("chr1", "chr2", "chr3", "chr4"), 
                                                  class = "factor"), 
                                sample = structure(c(1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L), 
                                                   .Label = c("sample_1", "sample_2"), 
                                                   class = "factor"),
                                average = c(358.017, 34.452, 409.7959, 117.0805, 345.6717, 34.3544, 362.3519, 110.7264), 
                                std_dev = c(1484.33280699, 97.332895241, 1460.24099656, 
                                            519.299214731, 1439.86318396, 114.04659662, 1340.67100158, 
                                            499.901605662)), 
                           .Names = c("chrom", "sample", "average", "std_dev"), 
                           row.names = c(1L, 2L, 3L, 4L, 25L, 26L, 27L, 28L), class = "data.frame")
  
  
  &gt; sample_data
     chrom   sample  average   std_dev
  1   chr1 sample_1 358.0170 1484.3328
  2   chr2 sample_1  34.4520   97.3329
  3   chr3 sample_1 409.7959 1460.2410
  4   chr4 sample_1 117.0805  519.2992
  25  chr1 sample_2 345.6717 1439.8632
  26  chr2 sample_2  34.3544  114.0466
  27  chr3 sample_2 362.3519 1340.6710
  28  chr4 sample_2 110.7264  499.9016
  </code></pre>
  
  <p>I want to make a line plot for each <code>sample</code> <code>average</code> (y) per <code>chrom</code> (x), with a ribbon showing the standard deviation (<code>std_dev</code>) range. So I came up with this code:</p>
  
  <pre><code>sample_ribbon &lt;- ggplot(sample_data, x=chrom, y=average, group=sample)
  sample_ribbon &lt;- sample_ribbon + geom_line()
  sample_ribbon &lt;- sample_ribbon + geom_ribbon(aes(x=chrom, ymin=average - std_dev, ymax=average + std_dev), alpha = 0.3)
  print(sample_ribbon)
  </code></pre>
  
  <p>However, I keep getting this error:</p>
  
  <pre><code>Error in order(data$PANEL, data$group, data$x) : 
  argument 3 is not a vector
  </code></pre>
  
  <p>Any idea what is wrong with this? I have tried multiple methods to plot this and they all come back with this error. </p>