Select a vector element using a ranked set of preferences.

preferred_choice(x, preferences, default = 1, missing = NA)

Arguments

x

Named vector of possible choices

preferences

Ranked vector of names of x

default

Element of x if none of preferences are names of x

missing

Value returned instead of x[default], when default=0 or none of preferences or default exist in names(x)