Currently, we're using na_rm to remove all points where x, y, or deriv are NA
However, we only need to be so strict for the point where deriv is at a max. For the other uses of x and y (i.e. finding the intersection point, it's sufficient to use points where x and y are not NA (regardless of if deriv is NA).
To fix, need to keep two sets of x and y through the function. One set where they've been removed when deriv is NA, and one set where they've only been removed when x or y is NA
Actually, it's sufficient to simply use y values that aren't NA themselves, they don't need to be y values where x isn't NA. We could probably warn when min(y) != min(y[!is.na(x)])
Currently, we're using na_rm to remove all points where x, y, or deriv are NA
However, we only need to be so strict for the point where deriv is at a max. For the other uses of x and y (i.e. finding the intersection point, it's sufficient to use points where x and y are not NA (regardless of if deriv is NA).
To fix, need to keep two sets of x and y through the function. One set where they've been removed when deriv is NA, and one set where they've only been removed when x or y is NA