How can I find the index of an element, when the element is determined using quantile()
? The match()
and which()
solutions from this similar question do not work (they return NA), and I think they don't work because of rounding issues.
In the case that the quantile result is averaged/interpolated across two indices, can I specify if it takes the lower/higher index? My data x
will always be sorted.
Example Dataset (Obviously the 0 and 1 quantiles here are just the min and max, they are just shown for a sanity check)
x <- c(0.000000e+00,9.771228e-09,5.864592e-06,3.474925e-04,9.083242e-04,2.458036e-02) quantile(x, probs = c(0, 0.5, 1)) 0% 50% 100% 0.0000000000 0.0001766785 0.0245803600
How do I find the indices for these quantiles? Here, the indices are 1,??,6
. And I guess the median is the average of two indices, so can I specific that it returns the first or second index?
没有评论:
发表评论