title: ggplot: Plotting the bins on x-axis and the average on y-axis
body: <p>Suppose that I have a dataframe that looks like this:</p>
  
  <pre><code>data &lt;- data.frame(y = rnorm(10,0,1), x = runif(10,0,1))
  </code></pre>
  
  <p>What I would like to do is to cut the x values into bins, such as:</p>
  
  <pre><code>data$bins &lt;- cut(data$x,breaks = 4)
  </code></pre>
  
  <p>Then, I would like to plot (using ggplot) the result in a way that the x-axis is the bins, and the y axis is the mean of data$y data points that fall into the corresponding bin.</p>
  
  <p>Thank you in advance</p>