Skip to contents

For bivariate data that show monotonic decreases (e.g. plots of trajectory count vs. frame gap allowed, or scree plots from PCAs), this function will find the "elbow" point. This is done by drawing an (imaginary) line between the first observation and the final observation. Then, the distance between that line and each observation is calculated. The "elbow" of the curve is the observation that maximizes this distance.

Usage

find_curve_elbow(data_frame, export_type = "row_num", plot_curve = FALSE)

Arguments

data_frame

A two-column data frame (numeric entries only), ordered x-axis first, y-axis second.

export_type

If "row_num" (the default), the row number of the elbow point is returned. If anything else, the entire row of the original data frame is returned.

plot_curve

Default FALSE; should the curve be plotted?

Value

If export_type is row_num the row number of the elbow point is returned. If anything else is used for that argument, the entire row of the original data frame on which the "elbow" is located is returned. If plot_curve is TRUE, the curve is plotted along with a vertical line drawn at the computed elbow point.

Author

Vikram B. Baliga

Examples

df <- data.frame(x = seq(1:10),
                 y = 1/seq(1:10))
plot(df)

find_curve_elbow(df, plot_curve = TRUE)

#> [1] 3