icd9LongToWide(icd9df, visitId = NULL, icd9Field = NULL, prefix = "icd_", min.width = 0, aggregate = TRUE, return.df = FALSE)NULL, then an
attempt is made to guess which field has the ID for the patient encounter
(not a patient ID, although this can of course be specified directly). The
guesses proceed until a single match is made. Data frames may be wide with
many matching fields, so to avoid false positives, anything but a single
match is rejected. If there are no successful guesses, and visitId
was not specified, then the first column of the data frame is used.NULL, icd9
will attempt to guess the column name, looking for progressively less
likely possibilities until it matche a single column. Failing this, it will
take the first column in the data frame. Specifying the column using this
argument avoids the guesswork.FALSE, then out-of-order visitIds will result in
a row in the output data per contiguous block of identical visitIds.TRUE, return a data frame
with a field for the visitId. This may be more convenient, but the default
of FALSE gives the more natural return data of a matrix with
rownames being the visitIds.icd9ChaptersToMap,
icd9DropLeadingZeroes,
icd9PartsToShort,
icd9WideToLong
longdf <- data.frame(visitId = c("a", "b", "b", "c"),
icd9 = c("441", "4424", "443", "441"))
icd9LongToWide(longdf)
icd9LongToWide(longdf, prefix = "ICD10_")
Run the code above in your browser using DataLab