Description Usage Arguments See Also Examples
This is more complicated than reshape or reshape2::dcast allows. This is a reasonably simple solution using built-in functions.
1 2 |
icd9df |
data.frame of long-form data, one column for visitId and one for ICD code |
visitId |
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. If left empty, or |
icd9Field |
The column in the data frame which contains the ICD codes.
This is a character vector of length one. If it is |
prefix |
character, default "icd_" to prefix new columns |
min.width, |
single integer, if specified, writes out this many columns even if no patients have that many codes. Must be greater than or equal to the maximum number of codes per patient. |
aggregate |
single logical value, if TRUE (the default) will take more
time to find out-of-order visitIds, and combine all the codes for each
unique visitId. If |
return.df |
single logical value, if |
Other ICD-9 convert: icd9ChaptersToMap
,
icd9DropLeadingZeroes
,
icd9PartsToShort
,
icd9WideToLong
1 2 3 4 | longdf <- data.frame(visitId = c("a", "b", "b", "c"),
icd9 = c("441", "4424", "443", "441"))
icd9LongToWide(longdf)
icd9LongToWide(longdf, prefix = "ICD10_")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.