getAdmLimits | R Documentation |
Adds first admission date and last discharge date to a sequence of admissions. The default input data.table is the current standard by which admissions are available in Statistics Denmark.
getAdmLimits(
dt,
pnr = "pnr",
inddto = "inddto",
uddto = "uddto",
keep = NULL,
collapse = FALSE,
error = "warn"
)
dt |
data.table containing the variables |
pnr |
Variable with ID for each subject/group (default is |
inddto |
Variable with entry times. Must be date or numeric (default is |
uddto |
Variable with exit times. Must be date or numeric (default is |
keep |
Vector of names of variables of |
collapse |
if |
error |
Character. One of |
data.table with two new variables first.indate and last.outdate.
Thomas A. Gerds <tag@biostat.ku.dk>
set.seed(8)
lpr <- simAdmissionData(10)
## Variables have default names
adm <- getAdmLimits(lpr)
## with errors
lpr1 <- lpr
lpr1 <- lpr1[uddto>as.Date("2010-01-01"),uddto:=NA]
adm1 <- getAdmLimits(lpr1)
adm1 <- getAdmLimits(lpr1,error="remove")
adm1 <- getAdmLimits(lpr1,error="flag")
## case where Variables have custom names
data.table::setnames(lpr, c('pnr','inddto','uddto'), c('personid', 'Entrydate','Outdate'))
adm2 <- getAdmLimits(lpr,pnr='personid',inddto='Entrydate',uddto='Outdate')
## duplicated and overlap
set.seed(8)
lpr3 <- simAdmissionData(10)
lpr3 <- lpr3[sample(1:NROW(lpr3),replace=TRUE,size=round(NROW(lpr3)*1.5))]
adm3 <- getAdmLimits(lpr3,collapse=TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.