set_classcodes: Set classcodes object

View source: R/set_classcodes.R

set_classcodesR Documentation

Set classcodes object

Description

Prepare a classcodesobject by specifying the regular expressions to use for classification.

Usage

set_classcodes(
  cc,
  classified = NULL,
  regex = NULL,
  start = TRUE,
  stop = FALSE,
  tech_names = NULL
)

Arguments

cc

classcodes object (or name of a default object from all_classcodes()).

classified

object that classcodes could be inherited from

regex

name of column with regular expressions to use for classification. NULL (default) uses attr(obj, "regexpr")[1].

start, stop

should codes start/end with the specified regular expressions? If TRUE, column "regex" is prefixed/suffixed by ^/$.

tech_names

should technical column names be used? If FALSE, colnames are taken directly from group names of cc, if TRUE, these are changed to more technical names avoiding special characters and are prefixed by the name of the classification scheme. NULL (by default) preserves previous names if cc is inherited from classified (fall backs to FALSE if not already set).

Value

classcodes object.

See Also

Other classcodes: all_classcodes(), as.data.frame.classified(), classcodes, codebook(), print.classcodes(), print.classified(), summary.classcodes(), visualize.classcodes()

Examples

# Prepare a classcodes object for the Charlson comorbidity classification
# based on the default regular expressions
set_classcodes(charlson)   # by object
set_classcodes("charlson") # by name

# Same as above but based on regular expressions for ICD-8 (see `?charlson`)
set_classcodes(charlson, regex = "icd8_brusselaers")

# Only recognize codes if no other characters are found after the relevant codes
# Hence if the code vector stops with the code
set_classcodes(charlson, stop = TRUE)

# Accept code vectors with strings which do not necessarily start with the code.
# This is useful if the code might appear in the middle of a longer character
# string or if a common prefix is used for all codes.
set_classcodes(charlson, start = FALSE)

# Use technical names to clearly describe the origin of each group.
# Note that the `cc` argument must be specified by a character string
# since this name is used as part of the column names
x <- set_classcodes("charlson", tech_names = TRUE)
x$group

eribul/coder documentation built on March 16, 2023, 12:50 a.m.