title: ggplot2: object 'y' not found with stat="bin"
body: <p>I'm sorry to ask a question that has been asked <a href="https://stackoverflow.com/questions/9974666/ggplot2-stacked-bar-chart-object-y-not-found">before</a> on SO, but I'm trying to plot some <a href="https://douglas-duhaime.squarespace.com/s/cleaned_estc_visuals.txt" rel="nofollow noreferrer">simple data</a>  in ggplot2 and am having trouble binning the data along the x-axis. My data consists of visual elements in old books (diagrams, engravings, etc.), and I can plot the frequency of each type of visual element in each year:</p>
  
  <pre><code>#this works
  df &lt;- read.table("cleaned_estc_visuals.txt",
                   header = F,
                   sep = "\t")
  
  ggplot(data=df, aes(x=V1, y=V3)) + 
    geom_bar(aes(fill=V2),stat="identity") +
    labs(title = "Visuals in Early Modern Books",fill="") +
    xlab("Year") + 
    ylab("Titles") 
  </code></pre>
  
  <p>This yields:
  <img src="https://i.stack.imgur.com/ECbfE.png" alt="enter image description here"></p>
  
  <p>To make the data more legible, I want to bin the values along the x-axis by decade, but can't quite seem to get the call right:</p>
  
  <pre><code>#this doesn't
  ggplot(data=df, aes(x=V1, y=V3)) + 
    geom_bar(aes(fill=V2),binwidth=10,stat="bin")
  </code></pre>
  
  <p>Running the latter code, I get:</p>
  
  <pre><code>Mapping a variable to y and also using stat="bin".
    With stat="bin", it will attempt to set the y value to the count of cases in each group.
    This can result in unexpected behavior and will not be allowed in a future version of ggplot2.
    If you want y to represent counts of cases, use stat="bin" and don't map a variable to y.
    If you want y to represent values in the data, use stat="identity".
    See ?geom_bar for examples. (Deprecated; last used in version 0.9.2)
  Error in pmin(y, 0) : object 'y' not found
  </code></pre>
  
  <p>Does anyone know how I can bin by decade along the x-axis? I would be grateful for any advice others can offer.</p>