Description Usage Arguments Details Value See Also Examples
The codelist class is a data.table defining a Read, ICD-10 or OPCS codelist with categories and metadata.
It can be generated by as.codelist
from the master dictionary, a text file or a vector of ICD-10 / OPCS codes.
Note that unlike a link{selection}
, codelists can only contain terms in one source dictionary,
but they can have categories and associated metadata.
1 2 3 4 5 6 7 8 9 |
x |
for |
Name |
new name for the codelist. The naming convention is for GPRD (Read) codelists to end in _gprd, ICD-10 codelists to end in _hes, OPCS (procedure) codelists to end in _opcs and GPRD drug codelists to end in _gprddrug. |
Version |
Version number, to be supplied as a character string or a number. Versions 0, 0.1, 0.2 ... should be used for unapproved (development) versions, and versions 1, 2 etc. for approved codelists. The version number is incremented if any terms are added to the codelist or the categories are changed. |
Author |
a string of author names, or a character vector of names, or a vector of |
Date |
a Date object or character string representing the date on which the codelist was created. |
Categories |
the categories table, in the form of a data.table with columns |
Source |
a string representing the data source. For the master dictionary, it can be a space or comma separated list or a vector of strings if multiple dictionaries are in use (but only one distinct source per dictionary). Options are 'GPRD' for Read codelists, 'HES' or 'ONS' for ICD-10 codelists, 'OPCS' for OPCS codelists, and 'ONSICD9' for ICD-9 codelists. A particular Source can only be associated with a single dictionary at a time (e.g. it is not possible to export a codelist to HES and ONS simultaneously; instead one has to export one version, use SetMetadata to update the source and then export the other). The allowable Source / dictionary combinations are hard-coded in the |
subset |
a logical vector as long as the number of terms in the codelist, denoting which to select (all rows are selected if it is missing). This is evaluated within the environment of the codelist, so column names do not need to be quoted. |
select |
Character vector of columns to select. Default is to select all columns. If the code or category columns are not selected, the output of the function is no longer a codelist object. |
... |
Other optional arguments to |
If x
is null, terms from the currently selected dictionary with a positive category assigned in CALIBER_DICT
are
used. If x
is the name of a source dictionary (read, icd10 or opcs), codes from that dictionary with a positive category
are used. If x
is a filename for a text file or Stata .dta file, it is imported as a codelist. If x
is a
selection
object, the selected terms comprise the new codelist with category = 1.
The codelist class inherits from data.table so most of the data.table functions are available, but if the data.table is copied or its size is changed using standard data.table methods, the new object may be a plain data.table rather than a codelist and its attributes may be lost.
Therefore a subset
method for codelists is provided to ensure that a subset of a codelist remains a codelist.
Codelists are data.table objects and are therefore passed by reference, not by value. In order to
create a copy of the codelist you must use the copy
function of data.table. This copies the attributes of the data.table including its class, and ensures that it remains as a data.table. If you assign
a codelist to a new name, both names will refer to the samy underlying codelist.
as.codelist
returns a codelist object
print.codelist
prints the codelist to screen
is.codelist
returns TRUE or FALSE
subset.codelist
returns a subset of the codelist which is either a codelist or a data.table
compare
, contractCodelist
, export
, expandCodelist
, merge.codelist
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | setdictionary('read')
mycodelist <- as.codelist(termhas('unstable angina'))
print(mycodelist)
is.codelist(mycodelist)
# Create a codelist from Read codes
af_gprd <- codelist(data.frame(
readcode=c('G573000', 'G573200', 'G573300', 'G573400', 'G573500')))
af_gprd
# Create a codelist from ICD-10 codes
# Allow a different spelling of icd_code
mi <- codelist(data.frame(icd.Code=c('I21', 'I22', 'I23')))
mi
mi_contract <- contractCodelist(mi)
mi_contract
# Convert to Read codes
mi_gprd1 <- convert(mi, 'read')
mi_gprd2 <- convert(mi_contract, 'read')
# Show that the GPRD codelists are the same whether from expanded
# or contracted ICD-10 lists
compare(mi_gprd1, mi_gprd2)
# Create a codelist from OPCS codes (use an unusual spelling of opcs_code)
af_opcs <- codelist(data.frame(OPCS.CODES=c('K621', 'K622', 'K623')))
af_opcs
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.