powered by
piecewise(x, y, abs = FALSE)
trapz
x <- c(0, 2, 3, 4, 5) y <- c(2, -2, 0, -2, 0) piecewise(x, y) piecewise(x, y, abs=TRUE)
Run the code above in your browser using DataLab