Get and set categories table for the master dictionary

Share:

Description

These functions retrieve or save the categories table to/from the META table (which is inside the CALIBERcodelists namespace), or retrieve the categories table from a codelist.

Usage

1
2
3
4
5
6
retrieveCategories(codelist = NULL)
saveCategories(numbers, shortnames = NULL, descriptions = NULL,
    cattable = NULL, codelist = NULL)
addCategory(number, shortname, description = "",
    codelist = NULL)
removeUnusedCategories(codelist = NULL)

Arguments

codelist

codelist to retrieve categories from, or save/retrieve to/from META if NULL.

numbers

integer vector of category numbers for the entire categories table

shortnames

character vector of short category descriptions for the entire categories table

descriptions

character vector of full category descriptions for the entire categories table

cattable

a data.table containing the new categories table with columns: category, shortname, description (i.e. in the same format as returned by retrieve_categories)

number

a single new category number

shortname

character vector of a new category shortname to add

description

character vector of a new full category description to add

Details

saveCategories saves the categories to META, in the form of three strings which are elements in the 'value' column alongside the 'item' entries: category, shortname and description (see META).

removeUnusedCategories removes unused category levels from a codelist, or from META if no codelist is given.

Value

retrieveCategories returns a data.table containing the category numbers, shortnames and descriptions. saveCategories invisibly returns the subset of META containing the category table. removeUnusedCategories invisibly returns the modified codelist or the subset of META containing the category table.

See Also

as.codelist, assigncat

Examples

1
2
3
4
5
retrieveCategories()

saveCategories(numbers=c(1, 2),
	shortnames=c('SA', 'UA'),
	descriptions=c('Stable angina', 'Unstable angina'))

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.