chooseByPriority {CALIBERdatamanage}R Documentation

Chooses an item from a vector according to a defined priority order

Description

Chooses a single item of x according to the priority order choice_order

Usage

chooseByPriority(x, choice_order)

Arguments

x

a numeric vector

choice_order

a numeric vector giving the order of priorities. Items near the front of the vector have higher priority.

Value

returns the value of choice_order with the smallest index that is in x. NA if no element of x occurs in choice_order.

Note

Used by addToCohort to select a single entry per patient.

See Also

addToCohort, addCodelistToCohort

Examples

##
chooseByPriority(1:4, 3:5) # returns 3
chooseByPriority(1:4, 5:7) # returns NA

[Package CALIBERdatamanage version 0.1-14 Index]