auc: Area under curve by trapezoidal integration

Description Usage Arguments Value Author(s) Examples

View source: R/auc.R

Description

Calculates the area under curve based on the trapezoidal integration method.

Usage

1
auc(time, resp)

Arguments

time

A vector with the time numeric variable.

resp

A vector with the response numeric variable.

Value

Returns the area under the curve based on the trapezoidal method.

Author(s)

Walmes Zeviani, walmes@ufpr.br.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
x <- 1:5
y <- c(1, 2, 3, 2, 1)

plot(y ~ x,
     type = "o",
     ylim = c(0, max(y)),
     asp = 1)
polygon(x = c(x, rev(x)),
        y = c(y, 0 * y),
        border = NA,
        col = "purple")
abline(v = x, h = x, lty = 2, col = "gray")

# Area for the colored region.
auc(time = x, resp = y)

walmes/wzRfun documentation built on Aug. 10, 2021, 2:19 p.m.