Return the middle x percent of values
Arguments
- x
numeric vector
- middle
percentage you want to center around
- within
percentage around center
Examples
x <- runif(20)
near_middle(x = x,
middle = 0.5,
within = 0.2)
#> [1] FALSE FALSE FALSE FALSE TRUE FALSE FALSE FALSE TRUE FALSE FALSE FALSE
#> [13] FALSE FALSE TRUE FALSE FALSE TRUE FALSE FALSE
library(dplyr)
heights %>% features(height_cm, list(min = min)) %>%
filter(near_middle(min, 0.5, 0.1))
#> # A tibble: 14 × 2
#> country min
#> <chr> <dbl>
#> 1 Brazil 164.
#> 2 Cameroon 164.
#> 3 Estonia 165.
#> 4 Gabon 164.
#> 5 Ghana 164.
#> 6 Guinea 164.
#> 7 Kenya 165.
#> 8 Kyrgyzstan 164.
#> 9 Latvia 165.
#> 10 Lithuania 165.
#> 11 Netherlands 164.
#> 12 Switzerland 165.
#> 13 Tajikistan 165.
#> 14 Uganda 165.