title: How to calculate the area under a frequency polygon in R?
body: <p>I am an struggeling to find a way of calculating the area under a frequency polygon like this:</p>
  <pre><code>x1 &lt;- 1:5                         
  y1 &lt;- c(0.2, 0.14, 0.7, 0.11, 0.1) 
  plot(x1, y1, type = &quot;l&quot;, lwd = 3)   
  polygon(c(1, x1, 5), c(0, y1, 0), col = &quot;red&quot;) 
  points(x1, y1,cex = 2,pch = 15)
  segments(x1, 0, x1, y1)
  
  </code></pre>
  <p>so basically the area of the red zone from 1 to 5..
  any suggestion would be much appreciated!!
  Many thanks</p>