Skip to contents

Get the name of the item(s) assigned a specific rank, e.g., first.

Usage

pref_get_items(x, rank, drop = FALSE)

Arguments

x

A vector of preferences.

rank

A single integer, the rank which you would like to inspect.

drop

When FALSE (default), blank preferences will remain. When TRUE, blank preferences will be omitted.

Value

A list containing the name(s) of the item(s) ranked rank in each of the preferences in x.

Examples

# Get items ranked first
pref_get_items(preferences(c("a > b > c", "b = c > a")), rank = 1)
#> [[1]]
#> [1] "a"
#> 
#> [[2]]
#> [1] "b" "c"
#> 
# Get items ranked second
pref_get_items(preferences(c("a > b > c", "b = c > a")), rank = 2)
#> [[1]]
#> [1] "b"
#> 
#> [[2]]
#> [1] "a"
#> 
# Get items ranked first, dropping blank preferences
pref_get_items(preferences(c("a > b > c", "", "b = c > a")), rank = 1, drop = TRUE)
#> [[1]]
#> [1] "a"
#> 
#> [[2]]
#> [1] "b" "c"
#>