Learn R Programming

prefio (version 0.2.0)

pref_pop: Eliminate lowest (or highest) ranked items from preferences.

Description

Eliminate lowest (or highest) ranked items from preferences.

Usage

pref_pop(x, n = 1L, lowest = TRUE, drop = FALSE)

Value

A new vector of preferences which is equal to x but with the least preferred selection dropped for each selection.

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.

Examples

Run this code
# Remove the lowest ranked item from each preference
pref_pop(preferences(c("a > b > c", "b > c > a")))

# Remove the 2 lowest ranked items
pref_pop(preferences(c("a > b > c > d", "b > c > a > d")), n = 2)

# Remove the highest ranked item instead
pref_pop(preferences(c("a > b > c", "b > c > a")), lowest = FALSE)

# Remove blank preferences that result from popping
pref_pop(preferences(c("a > b", "c", "")), drop = TRUE)

Run the code above in your browser using DataLab