Eliminate lowest (or highest) ranked items from preferences.
Arguments
- x
A vector of
preferences
.- n
The number of times to remove the bottom rank.
- lowest
If
TRUE
, eliminates the lowest ranked item(s) for each selection.- drop
If
TRUE
, drops blank preferences from the output.
Value
A new vector of preferences which is equal to x
but with the least
preferred selection dropped for each selection.
Examples
# Remove the lowest ranked item from each preference
pref_pop(preferences(c("a > b > c", "b > c > a")))
#> [1] [a > b] [b > c]
# Remove the 2 lowest ranked items
pref_pop(preferences(c("a > b > c > d", "b > c > a > d")), n = 2)
#> [1] [a > b] [b > c]
# Remove the highest ranked item instead
pref_pop(preferences(c("a > b > c", "b > c > a")), lowest = FALSE)
#> [1] [b > c] [c > a]
# Remove blank preferences that result from popping
pref_pop(preferences(c("a > b", "c", "")), drop = TRUE)
#> [1] [a]