This is different enough to dcast
in reshape2
that
it needs writing again specifically for ICD codes. This function packages
the core reshape
function. Empty strings and NA values will be
dropped, and everything else kept. No validation of the ICD codes is done.
icd9WideToLong(x, visitId = NULL, icd.labels = NULL, icd.name = "icdCode")
data.frame
in wide format, i.e. one row per patient, and
multiple columns containing ICD codes, empty strings or NA.
The name of the column in the data frame which contains the patient or visit identifier. Typically this is the visit identifier, since patients come leave and enter hospital with different ICD-9 codes. It is a character vector of length one. Defaults to "visitId"
vector of column names in which codes are found. If NULL, all columns matching icd or ICD will be included.
character vector length one containing the new column name for the ICD codes, defaults to "icd9Code"
data frame with visitId column named the same as input, and a column
named by icd.name
containing all the non-NA and non-empty codes
found in the wide input data.
Other ICD-9 convert: convert
,
convert
, icd9DecimalToParts
,
icd9DecimalToShort
,
icd9GetMajor
,
icd9MajMinToCode
,
icd9MajMinToDecimal
,
icd9MajMinToParts
,
icd9MajMinToShort
,
icd9PartsToDecimal
,
icd9PartsToShort
,
icd9ShortToDecimal
,
icd9ShortToParts
;
icd9ChaptersToMap
;
icd9DropLeadingZeroes
,
icd9DropLeadingZeroesDecimal
,
icd9DropLeadingZeroesMajor
,
icd9DropLeadingZeroesShort
;
icd9LongToWide
# NOT RUN {
widedf <- data.frame(visitId = c("a", "b", "c"),
icd9_01 = c("441", "4424", "441"),
icd9_02 = c(NA, "443", NA))
icd9WideToLong(widedf)
# }
Run the code above in your browser using DataLab