View source: R/truncate_linelist.R
truncate_linelist | R Documentation |
Adjust or subset the line list <data.frame>
by removing cases that
have not been reported by the truncation time and setting hospitalisation
admission or outcome dates that are after the truncation point to NA
.
This is to replicate real-time outbreak data where recent cases or outcomes are not yet observed or reported (right truncation). It implies an assumption that symptom onsets are reported with a delay but hospitalisations are reported instantly.
truncate_linelist(
linelist,
truncation_day = 14,
unit = c("days", "weeks", "months", "years"),
direction = c("backwards", "forwards")
)
linelist |
Line list |
truncation_day |
A single Alternatively, |
unit |
A Years are assumed to be 365.25 days and months are assumed to be 365.25 / 12 days (same as lubridate). |
direction |
A |
The day on which the line list is truncated is the same for
all individuals in the line list, and is specified by the
truncation_day
and unit
arguments.
A line list <data.frame>
.
set.seed(1)
linelist <- sim_linelist()
linelist_trunc <- truncate_linelist(linelist)
# set truncation point 3 weeks before the end of outbreak
linelist_trunc <- truncate_linelist(
linelist,
truncation_day = 3,
unit = "weeks"
)
# set truncation point to 2 months since the start of outbreak
linelist_trunc <- truncate_linelist(
linelist,
truncation_day = 2,
unit = "months",
direction = "forwards"
)
# set truncation point to 2023-03-01
linelist_trunc <- truncate_linelist(
linelist,
truncation_day = as.Date("2023-03-01")
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.