Find the percentile of the value specified in numeric vector.

get_percentile(x, value, from = 0, to = 1, eps = 1e-06)

Arguments

x

numeric. a numeric vector.

value

numeric. a scalar to find percentile value from vector x.

from

numeric. Start interval in logic to find percentile value. default to 0.

to

numeric. End interval in logic to find percentile value. default to 1.

eps

numeric. Threshold value for calculating the approximate value in recursive calling logic to find the percentile value. (epsilon). default to 1e-06.

Value

list. Components of list. is as follows.

  • percentile : numeric. Percentile position of value. It has a value between [0, 100].

  • is_outlier : logical. Whether value is an outlier.

Examples

carat <- ggplot2::diamonds$carat

quantile(carat)
#>   0%  25%  50%  75% 100% 
#> 0.20 0.40 0.70 1.04 5.01 

get_percentile(carat, value = 0.5)
#> $percentile
#> [1] 34.375
#> 
#> $is_outlier
#> [1] FALSE
#> 
get_percentile(carat, value = median(carat))
#> $percentile
#> [1] 50
#> 
#> $is_outlier
#> [1] FALSE
#> 
get_percentile(carat, value = 1)
#> $percentile
#> [1] 67.1875
#> 
#> $is_outlier
#> [1] FALSE
#> 
get_percentile(carat, value = 7)
#> $percentile
#> [1] 100
#> 
#> $is_outlier
#> [1] TRUE
#>