wide_vs_long: Set the ICD data structure class of a 'matrix' or...

Description Usage Arguments Functions Long and Wide Formats Data structure Conversion See Also Examples

Description

These functions take your patient data, and allow you to describe whether it is wide or long. icd never requires you do this, but it may help avoid errors, especially if you have atypical data that might confuse icd's heuristics.

Usage

1
2
3
4
5
6
7

Arguments

x

Input data is a matrix, data.frame, or a class that inherits one of these base structures, such as a tibble.

warn

Single logical, if TRUE, the default, a warning will be shown if changing class between long and wide types.

...

Data used to construct data frame before setting the appropriate class.

Functions

Long and Wide Formats

As is common with many data sets, key variables can be concentrated in one column or spread over several. Tools format of clinical and administrative hospital data, we can perform the conversion efficiently and accurately, while keeping some metadata about the codes intact, e.g. whether they are ICD-9 or ICD-10.

Data structure

Long or wide format ICD data are all expected to be in a data frame. The data.frame itself does not carry any ICD classes at the top level, even if it only contains one type of code; whereas its constituent columns may have a class specified, e.g. icd9 or icd10who.

Conversion

To convert between long and wide data, use long_to_wide or wide_to_long. Conversion functions in other packages, such as ddplyr will work, too, but will need some work to account for the typical structure of patient data and diagnostic codes. This is not done with ddplyr, data.table etc because it would add a big dependency burden. This package aims to be agnostic and use base R as much as possible.

See Also

long_to_wide and wide_to_long

Other ICD data types: as.comorbidity_map(), set_icd_class

Other ICD data types: as.comorbidity_map(), set_icd_class

Other ICD data types: as.comorbidity_map(), set_icd_class

Examples

1
2
3
4
5
6
7
8
(w <- icd_wide_data(
  id = c(1, 2, 3),
  dx01 = c("100", "441", "V20"),
  dx02 = c("E9981", "V10", "44004")
))
wide_to_long(w)
class(uranium_pathology)
class(vermont_dx)

icd documentation built on July 2, 2020, 4:07 a.m.