Description Usage Arguments See Also Examples
convert matrix of comorbidities into data frame, preserving visit_name information
1 2 3 4 5 | comorbid_mat_to_df(
x,
visit_name = "visit_id",
stringsAsFactors = getOption("stringsAsFactors")
)
|
x |
Matrix of comorbidities, with row and columns names defined |
visit_name |
Single character string with name for new column in output
data frame. Everywhere else, |
stringsAsFactors |
Single logical value, describing whether the resulting data frame should have strings, e.g.
|
Other ICD data conversion:
comorbid_df_to_mat()
,
convert
,
decimal_to_short()
,
long_to_wide()
,
short_to_decimal()
,
wide_to_long()
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | longdf <- icd_long_data(
visit_id = c("a", "b", "b", "c"),
icd9 = as.icd9(c("441", "4240", "443", "441"))
)
mat <- icd9_comorbid_elix(longdf)
class(mat)
typeof(mat)
rownames(mat)
df.out <- comorbid_mat_to_df(mat)
stopifnot(is.data.frame(df.out))
# output data frame has a factor for the visit_name column
stopifnot(identical(rownames(mat), as.character(df.out[["visit_id"]])))
df.out[, 1:4]
# when creating a data frame like this, stringsAsFactors uses
# the system-wide option you may have set e.g. with
# options("stringsAsFactors" = FALSE).
is.factor(df.out[["visit_id"]])
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.