This function takes a vector of x and y values
and returns a scalar for the area under the curve, calculated using
the trapezoid rule
Usage
auc(
x,
y,
xlim = NULL,
blank = 0,
subset = NULL,
na.rm = TRUE,
neg.rm = FALSE,
warn_xlim_out_of_range = TRUE,
warn_negative_y = TRUE
)Arguments
- x
numericvectorofxvalues- y
numericvectorofyvalues- xlim
vector, of length 2, delimiting thexrange over which the area under the curve should be calculated (whereNAcan be provided for the area to be calculated from the start or to the end of the data)- blank
Value to be subtracted from
yvalues before calculating area under the curve- subset
A
vectoroflogicalvalues indicating whichxandyvalues should be included (TRUE) or excluded (FALSE).- na.rm
a
logicalindicating whether missing values should be removed- neg.rm
a
logicalindicating whetheryvalues below zero should be treated as zeros. IfFALSE, area under the curve for negativeyvalues will be calculated normally, effectively subtracting from the returned value.- warn_xlim_out_of_range
logicalwhether warning should be issued whenxlimis lower than the lowestxvalue or higher than the highestxvalue.- warn_negative_y
logicalwhether warning should be issued whenneg.rm == FALSEbut someyvalues are below 0.