classcodes {coder}R Documentation

Classcodes methods

Description

classcodes are classification schemes based on regular expression stored in data frames. These are essential to the package and constitute the third part of the triad of case data, code data and a classification scheme.

Usage

as.classcodes(x, ...)

## S3 method for class 'classcodes'
as.classcodes(
  x,
  ...,
  regex = attr(x, "regexpr"),
  indices = attr(x, "indices"),
  hierarchy = attr(x, "hierarchy")
)

## S3 method for class 'data.frame'
as.classcodes(
  x,
  ...,
  regex = NULL,
  indices = NULL,
  hierarchy = attr(x, "hierarchy"),
  .name = NULL
)

is.classcodes(x)

Arguments

x

data frame with columns described in the details section. Alternatively a classcodes object to be modified.

...

arguments passed between methods#'

regex, indices

character vector with names of columns in x containing regular expressions/indices.

hierarchy

named list of pairwise group names to appear as superior and subordinate for indices. To be used for indexing when the subordinate class is redundant (see the details section of elixhauser for an example).

.name

used internally for name dispatch

Details

A classcodes object is a data frame with mandatory columns:

The object can have additional optional columns:

Value

Object of class classcodes (inheriting from data frame) with additional attributes:

See Also

vignette("classcodes") vignette("Interpret_regular_expressions") The package have several default classcodes included, see all_classcodes().

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

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

Examples

# The Elixhauser comorbidity classification is already a classcodes object
is.classcodes(coder::elixhauser)

# Strip its class attributes to use in examples
df <- as.data.frame(coder::elixhauser)

# Specify which columns store regular expressions and indices
# (assume no hierarchy)
elix <-
  as.classcodes(
    df,
    regex     = c("icd10", "icd10_short", "icd9cm", "icd9cm_ahrqweb", "icd9cm_enhanced"),
    indices   = c("sum_all", "sum_all_ahrq", "walraven",
                "sid29", "sid30", "ahrq_mort", "ahrq_readm"),
    hierarchy = NULL
  )
elix

# Specify hierarchy for patients with different types of cancer and diabetes
# See `?elixhauser` for details
as.classcodes(
  elix,
  hierarchy = list(
    cancer   = c("metastatic cancer", "solid tumor"),
    diabetes = c("diabetes complicated", "diabetes uncomplicated")
  )
)

# Several checks are performed to not allow any erroneous classcodes object
## Not run: 
  as.classcodes(iris)
  as.classcodes(iris, regex = "Species")

## End(Not run)

[Package coder version 0.13.10 Index]