codebook: codebook(s) for classcodes object

Description Usage Arguments Value See Also Examples

View source: R/codebook.R

Description

summary.classcodes() and visualize.classcodes() are used to summarize/visualize classcodes in R. A codebook, on the other hand, is an exported summary saved in an Excel spreadsheet to use in collaboration with non R-users. Several codebooks might be combined into a single Excel document with several sheets (one for each codebook).

Usage

1
2
3
4
5
6
codebook(object, coding, ..., file = NULL)

## S3 method for class 'codebook'
print(x, ...)

codebooks(..., file = NULL)

Arguments

object

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")

...

Additional arguments for each function:

  • codebook(): arguments passed to summary.classcodes()

  • codebooks(): multiple named outputs from codebook()

  • print.codebook(): arguments passed to tibble:::print.tbl()

file

name/path to Excel file for data export

x

output from codebook()

Value

Functions are primarily called for their side effects (exporting data to Excel or printing to screen). In addition:

See Also

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

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# codebook() --------------------------------------------------------------
## Not run: 
# Export codebook (to temporary file) with all codes identified by the
# Elixhauser comorbidity classification based on ICD-10-CM
codebook(elixhauser, "icd10cm", file = tempfile("codebook", fileext = ".xlsx"))

# All codes from ICD-9-CM Disease part used by Elixhauser enhanced version
codebook(elixhauser, "icd9cmd",
  cc_args = list(regex = "icd9cm_enhanced",
  file = tempfile("codebook", fileext = ".xlsx"))
)

# The codebook returns a list with three objects.
# Access a dictionary table with translates of each code to text:
codebook(charlson, "icd10cm")$all_codes

## End(Not run)

# print.codebook() --------------------------------------------------------

# If argument `file` is unspecified, a preview of each sheet of the codebook is
# printed to the screen
(cb <- codebook(charlson, "icd10cm"))

# The preview can be modified by arguments to the print-method
print(cb, n = 20)


# codebooks() -------------------------------------------------------------

# Combine codebooks based on different versions of the regular expressions
# and export to a single (temporary) Excel file
c1 <- codebook(elixhauser, "icd10cm")
c2 <- codebook(elixhauser, "icd9cmd",
  cc_args = list(regex = "icd9cm_enhanced")
  )

codebooks(
  elix_icd10 = c1, elix_icd9cm = c2,
  file = tempfile("codebooks", fileext = ".xlsx")
)

coder documentation built on Jan. 18, 2021, 5:07 p.m.