Return the middle x percent of values

near_middle(x, middle, within)

Arguments

x

numeric vector

middle

percentage you want to center around

within

percentage around center

Value

logical vector

Examples

x <- runif(20) near_middle(x = x, middle = 0.5, within = 0.2)
#> [1] FALSE FALSE FALSE FALSE FALSE FALSE TRUE FALSE TRUE FALSE TRUE FALSE #> [13] TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
library(dplyr) wages %>% features(ln_wages, list(min = min)) %>% filter(near_middle(min, 0.5, 0.1))
#> # A tibble: 88 x 2 #> id min #> <int> <dbl> #> 1 145 1.48 #> 2 316 1.46 #> 3 324 1.49 #> 4 356 1.49 #> 5 517 1.49 #> 6 735 1.46 #> 7 1300 1.49 #> 8 1417 1.48 #> 9 1515 1.48 #> 10 1535 1.48 #> # … with 78 more rows