I have a dataset with +1000 rows and I would compute the area under the line of each row. For example, suppose I have a dataset like this:
df<-rbind(c(0, 2, 0, 3, 0),
c(2, 2, 0, 1, 0))
For the first row, I would compute the area under the line in this figure:
which would be
> 2*2/2+2*3/2
[1] 5
And for the second row, it would be
> 1*2+1*2/2+2*1/2
[1] 4
I'm wondering whether there is an easy way to realize it in R?