icd9ComorbidMatToDf: convert matrix of comorbidities into data frame, preserving...

Description Usage Arguments Examples

View source: R/convert.R

Description

convert matrix of comorbidities into data frame, preserving visitId information

Usage

1
2
icd9ComorbidMatToDf(x, visitId = "visitId",
  stringsAsFactors = getOption("stringsAsFactors"))

Arguments

x

Matrix of comorbidities, with row and columns names defined

visitId

Single character string with name for new column in output data frame. Everywhere else, visitId describes the input data, but here it is for output data.

stringsAsFactors

whether the resulting data frame should have strings, i.e. visitId converted to factor. Default is to follow the current session option.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
longdf <- data.frame(visitId = c("a", "b", "b", "c"),
    icd9 = c("441", "4424", "443", "441"))
mat <- icd9ComorbidElix(longdf)
class(mat)
typeof(mat)
rownames(mat)
df.out <- icd9ComorbidMatToDf(mat)
stopifnot(is.data.frame(df.out))
# output data frame has a factor for the visitId column
stopifnot(identical(rownames(mat), as.character(df.out$visitId)))
df.out[, 1:4]

jackwasey/icd9 documentation built on May 18, 2019, 7:57 a.m.