title: R: Graphing binned data
body: <p>I am sorting data into bins and averaging, see <a href="https://stackoverflow.com/questions/5161055/binning-data-finding-results-by-group-and-plotting-using-r/5161200#5161200">this solution</a>.</p>
  
  <p>I am using the exact same solution as in the above link but fixing my data to a scatter plot instead. The code which is causing me difficulty is :</p>
  
  <pre><code>myData.class &lt;- cut(df$xaxis, seq(0,30,length=60), include.lowest=TRUE)
  mean.yaxis &lt;- tapply(df$yaxis, myData.class, mean)
  lines(mean.yaxis ~ seq(0, 30, length=60))
  </code></pre>
  
  <p>The call to lines is producing an error :</p>
  
  <pre><code>Error in model.frame.default(formula = mean.yaxis ~ seq(0, 30, length = 60),  : 
      variable lengths differ (found for 'seq(0, 30, length = 60)')
  </code></pre>
  
  <p>A call to str(mean.yaxis) produces :</p>
  
  <pre><code>num [1:59(1d)] 0 0 0 0.349 4.652 ...
  - attr(*, "dimnames")=List of 1
    ..$ : chr [1:59] "[0,0.508]" "(0.508,1.02]" "(1.02,1.53]" "(1.53,2.03]" ...
  </code></pre>
  
  <p>How can I access to correct data in my call to the function lines(...) ?</p>