title: adding layer to a plot in R
body: <p>Taking some generic data</p>
  
  <pre><code>A &lt;- c(1997,2000,2000,1998,2000,1997,1997,1997)
  B &lt;- c(0,0,1,0,0,1,0,0)
  df &lt;- data.frame(A,B)
  
  counts &lt;- t(table(A,B))
  frac &lt;- counts[1,]/(counts[2,]+counts[1,])
  
  
  C &lt;- c(1998,2001,2000,1995,2000,1996,1998,1999)
  D &lt;- c(1,0,1,0,0,1,0,1)
  df2 &lt;- data.frame(C,D)
  
  counts2 &lt;- t(table(C,D))
  frac2 &lt;- counts2[1,]/(counts2[2,]+counts2[1,])
  </code></pre>
  
  <p>If we then want to create a scatterplot for the two datasets on the one scale</p>
  
  <p>We can:</p>
  
  <pre><code>plot(frac, pch=22)
  points(frac2, pch=19)
  </code></pre>
  
  <p>But we see we have two problems</p>
  
  <ul>
  <li>first we want to put our year values (which appear as <code>df$A</code> and <code>df$C</code>) along the x axis</li>
  <li>We want the x axis to automatically adjust the scale when the second data is added.</li>
  </ul>
  
  <p>A solution using <code>ggplot2</code> or base R would be desired</p>