title: Can I avoid using data frames in ggplot2?
body: <p>I'm running a monte-carlo simulation and the output is in the form:</p>
  
  <pre><code>&gt; d = data.frame(iter=seq(1, 2), k1 = c(0.2, 0.6), k2=c(0.3, 0.4))
  &gt; d
  iter  k1   k2
  1     0.2  0.3
  2     0.6  0.4
  </code></pre>
  
  <p>The plots I want to generate are:</p>
  
  <pre><code>plot(d$iter, d$k1)
  plot(density(d$k1))
  </code></pre>
  
  <p>I know how to do equivalent plots using ggplot2,  convert to data frame</p>
  
  <pre><code>new_d = data.frame(iter=rep(d$iter, 2), 
                     k = c(d$k1, d$k2), 
                     label = rep(c('k1', 'k2'), each=2))
  </code></pre>
  
  <p>then plotting is easy. However the number of iterations can be very large and the number of k's can also be large. This means messing about with a very large data frame.</p>
  
  <p>Is there anyway I can avoid creating this new data frame?</p>
  
  <p>Thanks</p>