Description Usage Arguments Details Value Note See Also Examples
Assigns a set of terms to a category in the master dictionary (CALIBER_DICT
), and adds a category description to the category table.
1 2 |
number |
a number for the new category being allocated.
Only terms in one of the dictionaries currently being used (as set by |
definition |
Category description. A short and long form of the description can be given separated by | (e.g. 'MI|myocardial infarction'), in which case the short form will be listed in the exported CSV codelist and both forms will be in the HTML documentation. |
logic |
a selection object, as returned by one of the functions |
cats_to_convert |
An integer vector stating which previously assigned categories are permitted to be changed to the new category.
If this is blank, any terms can be changed to the new category regardless of their existing category.
If it is set to a range of previously assigned categories, only these categories can be changed by the new allocation.
This might be useful to mark previously selected terms for exclusion whilst ignoring terms meeting the exclusion
criteria if they were not previously included. NA can be included in the vector of |
dictionary |
To be used with |
codes |
To be used with |
The function setdictionary
must be called before assigncat
to specify which terms are eligible for selection and to initialise the categories table.
Note that it is not currently possible to add categories to a codelist using this method.
Codelists are intended to built using the master dictionaries and then exported in their final form.
However, the modifications can be created in a new codelist and the codelists combined using
merge.codelist
.
Returns the categories
table invisibly. Prints a message stating the number of codes assigned to the category.
A script for generating a codelist with many categories may have multiple assigncat
statements. Subsequent category allocations overwrite previous ones, so it is important to consider the order carefully in case some selected terms fulfil the criteria for more than one category.
as.codelist
, codematch
, dictis
, explode
, getdictionary
, setdictionary
, termhas
To combine codelists: merge.codelist
To compare codelists: compare
To convert codelists from one dictionary to another: convert
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | ## Setting up a codelist for cardiomyopathy terms
setdictionary('read')
mycodelist <- as.codelist(termhas('cardiomyopathy'))
mycodelist[, category:=1L]
print(mycodelist)
print(as.codelist('read'))
## Assigning category using a selection
assigncat(2, 'hcm|hypertrophic cardiomyopathy',
termhas('hyper*cardiomyopath'))
## Assigning category using Read codes
assigncat(3, 'hcm|hypertrophic cardiomyopathy',
dictionary='read', codes=c('12CJ.00', '12CR.00'))
## Show the selection
print(as.codelist())
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.