title: Get area size from geom_area (discrete values)
body: <p>I would like to get the area under a curve using ggplot2. The problem is that I have just discrete values (measurements, dependent variable) on a continuous scale (time), but measurements are not equally distant. I am not interested in fitting a function (I tried for analysis) but just the area under the plot.</p>
  
  <p>I know I could calculate means between x values and then do the "discrete integral". But I thought there might be an easier way to get just the area size, because I manage to draw the entire thing in ggplot2 using <code>geom_area</code>. So I get a neatly filled area, but is there any possibility of extracting the area size from <code>geom_area</code>?</p>
  
  <p><strong>EDIT:</strong> Below are some nice solutions to how to calculate the area under a curve where only discrete values are given. Still, if anyone knows if it's possible to extract the area size simply by <code>geom_area</code> I'm super curious to know!</p>
  
  <p>Reproducible example: </p>
  
  <pre><code>mydata &lt;- data.frame(time = c(2,4,6,8,19,24,30,43,48,69),
                       ratio = c(0.24, 1.04, 1.08, 1.27, 2.12, 2.13, 2.34, 2.00, 1.90, 1.96))
  
  ggplot(data = mydata, aes(x = time, y = ratio))+
    geom_area(fill = "grey")+
    geom_point(colour = "red")+
    labs(title = "My sample data", y = "Ratio", x = "Time")
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/5WwkQ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5WwkQ.png" alt="enter image description here"></a></p>