title: Adding a trend line to a scatterplot using R
body: <p>I have a data set with number of people at a certain age (ranging from 0-105+), recorded in the period 1846-2014, and I am making a scatterplot of the summed amount of people by year; there's one data set for males and one for females. After that, I am going to add a trend line, but I am having problems figuring out how.</p>
  
  <p>This is what I've got so far:</p>
  
  <pre><code>B &lt;- as.matrix(read.table("clipboard"))
  head(B)
  age &lt;- 0:105
  y &lt;- 1846:2014
  plot(c(1846:2014), c(colSums(B)), col=3, xlab="Year", ylab="Summed age", main="Summed people")
  </code></pre>
  
  <p>This gives me the plot, but I am not sure how to add the trend line. Please help.
  Plot looks like this: <a href="https://www.dropbox.com/s/5dono5bjrmqylcp/Plot.png?dl=0" rel="nofollow">https://www.dropbox.com/s/5dono5bjrmqylcp/Plot.png?dl=0</a></p>
  
  <p>Data available here:
  <a href="https://www.ssb.no/statistikkbanken/SelectVarVal/Define.asp?subjectcode=01&amp;ProductId=01&amp;MainTable=FolkemEttAarig&amp;SubTable=1&amp;PLanguage=1&amp;nvl=True&amp;Qid=0&amp;gruppe1=Hele&amp;gruppe2=Hele&amp;gruppe3=Hele&amp;VS1=AlleAldre00B&amp;VS2=Kjonn3&amp;VS3=&amp;mt=0&amp;KortNavnWeb=folkemengde&amp;CMSSubjectArea=befolkning&amp;StatVariant=&amp;checked=true" rel="nofollow">https://www.ssb.no/statistikkbanken/SelectVarVal/Define.asp?subjectcode=01&amp;ProductId=01&amp;MainTable=FolkemEttAarig&amp;SubTable=1&amp;PLanguage=1&amp;nvl=True&amp;Qid=0&amp;gruppe1=Hele&amp;gruppe2=Hele&amp;gruppe3=Hele&amp;VS1=AlleAldre00B&amp;VS2=Kjonn3&amp;VS3=&amp;mt=0&amp;KortNavnWeb=folkemengde&amp;CMSSubjectArea=befolkning&amp;StatVariant=&amp;checked=true</a></p>