as.keyvalue.classcodes: Make keyvalue object from classcodes object

View source: R/as.keyvalue.R

as.keyvalue.classcodesR Documentation

Make keyvalue object from classcodes object

Description

S3-method for generic decoder::as.keyvalue()

Usage

## S3 method for class 'classcodes'
as.keyvalue(x, coding, cc_args = list(), ...)

Arguments

x

classcodes object

coding

either a vector with codes from the original classification, or a name (character vector of length one) of a keyvalue object from package "decoder" (for example "icd10cm" or "atc")

cc_args

List of named arguments passed to set_classcodes()

...

additional arguments passed to decoder::as.keyvalue()

Value

Object of class keyvalue where key is the subset of codes from object$keyidentified by the regular expression from x and where value is the corresponding x$group. Hence, note that the original object$value is not used in the output.

Examples

# List all codes with corresponding classes as recognized by the Elixhauser
# comorbidity classification according to the Swedish version of the
# international classification of diseases version 10 (ICD-10-SE)
head(decoder::as.keyvalue(elixhauser, "icd10se"))

# Similar but with the American ICD-10-CM instead
# Note that the `value` column is similar as above
# (with names from `x$group`) and not
# from `object$value`
head(decoder::as.keyvalue(elixhauser, "icd10cm"))

# Codes identified by regular expressions based on ICD-9-CM and found in
# the Swedish version of ICD-9 used within the national cancer register
# (thus, a subset of the whole classification).
head(
  decoder::as.keyvalue(
    elixhauser, "icd9",
    cc_args = list(regex = "icd9cm")
  )
)

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