Skip to contents

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

Usage

# S3 method for 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"))
#> Classification based on: icd10
#>        key            value
#> 1453  A520 valvular disease
#> 501   B180    liver disease
#> 502  B180A    liver disease
#> 503  B180B    liver disease
#> 504  B180C    liver disease
#> 505  B180D    liver disease

# 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"))
#> Classification based on: icd10
#>        key            value
#> 3093 A5200 valvular disease
#> 3094 A5201 valvular disease
#> 3095 A5202 valvular disease
#> 3096 A5203 valvular disease
#> 3097 A5204 valvular disease
#> 3098 A5205 valvular disease

# 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")
  )
)
#>     key       value
#> 35 1400 solid tumor
#> 36 1401 solid tumor
#> 37 1403 solid tumor
#> 38 1404 solid tumor
#> 39 1405 solid tumor
#> 40 1406 solid tumor