selection {CALIBERcodelists} | R Documentation |
This class is used in the generation of codelists (see the codelist
class).
Selections differ from codelists in that they can contain terms from more than one
source dictionary, but they are Boolean (terms are included or not) without categories. Also they do not have any associated metadata, and are not allowed to have missing data.
The special Boolean operators %AND%
, %OR%
and NOT
can be used to combine selections, automatically coercing their arguments to selections (e.g. using termhas
if one of the arguments is a character string). They can also be combined using the conventional Boolean operators & (AND), | (OR) and ! (NOT), but the result will be a selection only if all the arguments are already selection objects.
selection(x = NULL, category = NULL, categories = NULL) as.selection(x, ...) is.selection(x)
x |
a codelist, character string or logical vector as long as the number of
rows in |
category |
if converting a codelist to a selection, a numeric vector of categories to include in the selection. |
categories |
alternative spelling for the |
... |
other arguments to pass to |
a selection object.
print.selection
, length.selection
.
Functions which return a selection: termhas
, codematch
setdictionary('opcs') # generating selections using codes or terms termhas('bronchoscop') codematch('E5[01]', 'opcs') # selection invokes termhas if the argument is a character string selection('bronchoscop') # the selection special Boolean operators automatically invoke # termhas if necessary termhas('bronchoscop') %AND% termhas('laser') termhas('bronchoscop') & termhas('laser') # if the argument to termhas is already a selection, # it is not modified termhas('bronchoscop' %AND% 'laser') 'bronchoscop' %AND% 'laser' 'bronchoscop' %AND% NOT('diagnostic')