Description Usage Arguments Details Value Author(s) See Also Examples
View source: R/extractEntity.R
Decodes additional clinical details (data1, data2, ... columns) in raw CPRD data using the lookups. CALIBER users should use the CALIBERlookups package, but it is also possible to supply the lookups directly.
1 2 | extractEntity(data, enttype, CALIBER_ENTITY = NULL,
CALIBER_LOOKUPS = NULL, ...)
|
data |
data.table or FFDF data frame containing the CPRD GOLD format data. |
enttype |
entity type(s) to extract, either a single integer or a vector. If extracting multiple entity types, the data specification for each entity type must be identical. |
CALIBER_ENTITY |
a table with columns enttype, data_fields, data1, data1_lkup, .... This argument can be omitted if the CALIBERlookups package is installed. |
CALIBER_LOOKUPS |
a table with columns lookup, category, description. This argument can be omitted if the CALIBERlookups package is installed. |
... |
other arguments to pass to |
If the CALIBERlookups package is not installed, CALIBER_ENTITY and CALIBER_LOOKUPS must be supplied.
CALIBER_ENTITY states what each of the data entries contains for a particular entity type, and is a data.table with columns:
enttypeinteger vector, key column, link to test or clinical table
descriptiona character vector
filetypea character vector, ‘Clinical’ or ‘Test’
categorya character vector
data_fieldsnumber of data fields used
data1definition of data1
data1_lkuplookup table for data1
data2definition of data2
data2_lkuplookup table for data2
data3definition of data3
data3_lkuplookup table for data3
data4definition of data4
data4_lkuplookup table for data4
data5definition of data5
data5_lkuplookup table for data5
data6definition of data6
data6_lkuplookup table for data6
data7definition of data7
data7_lkuplookup table for data7
data8definition of data8
data8_lkuplookup table for data8
If there are fewer than 8 data fields, the additional data columns are not required.
CALIBER_LOOKUPS contains the interpretation of each of the lookup categories, and is a data.table with columns:
lookupcharacter vector, first key column
categoryinteger vector, second key column
descriptioncharacter vector
extractEntity returns a data.table with interpreted entity data. The exact columns depend on
the entity type.
extractMedcodes returns a data.table or ffdf depending on the format of the original data.
The new column named varname is a factor with levels given by the category labels (shortnames) in the codelist.
Anoop Shah
addCodelistToCohort, addToCohort, extractCodes
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | data(test_data)
TESTDT <- data.table(test_data)
convertDates(TESTDT)
TESTFFDF <- as.ffdf(TESTDT)
data(test_entity)
ENTITY <- as.data.table(test_entity)
data(test_lookups)
LOOKUPS <- as.data.table(test_lookups)
LOOKUPS[, description := as.character(description)]
LOOKUPS[, lookup := as.character(lookup)]
extractEntity(TESTFFDF, 1, ENTITY, LOOKUPS)
extractEntity(TESTDT, 1, ENTITY, LOOKUPS)
extractEntity(TESTFFDF, 4, ENTITY, LOOKUPS)
extractEntity(TESTDT, 4, ENTITY, LOOKUPS)
extractEntity(TESTFFDF, 5, ENTITY, LOOKUPS)
extractEntity(TESTDT, 5, ENTITY, LOOKUPS)
extractEntity(TESTFFDF, 151, ENTITY, LOOKUPS)
extractEntity(TESTDT, 151, ENTITY, LOOKUPS)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.