Find the "elbow" of a curve.Source:
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.
A two-column data frame (numeric entries only), ordered x-axis first, y-axis second.
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.
Default FALSE; should the curve be plotted?
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.
TRUE, the curve is plotted along with a
vertical line drawn at the computed elbow point.
Other mathematical functions:
df <- data.frame(x = seq(1:10), y = 1/seq(1:10)) plot(df) find_curve_elbow(df, plot_curve = TRUE) #>  3