View source: R/censor_linelist.R
censor_linelist | R Documentation |
Censor <Date>
columns in line list output from sim_linelist()
to a
specified time interval.
This function is similar to incidence2::incidence()
but does not aggregate
events into an <incidence2>
object, instead it returns the same line list
<data.frame>
as input but with modified event dates.
censor_linelist(
linelist,
interval,
reporting_artefact = c("none", "weekend_effects"),
offset = min(linelist$date_onset, na.rm = TRUE)
)
linelist |
Line list |
interval |
An
See details for information of the date/period objects that are returned for each interval type. |
reporting_artefact |
A |
offset |
An Default date used to start counting from for the If setting |
The line list columns that contain <Date>
objects are stored at double
point precision by default. In other words, they are not integer
values,
so can be part way through a day. The exact numeric value of the <Date>
can be seen if you unclass()
it.
Censoring line list dates reduces the time precision (window) of the event.
Often dates of events, such as symptom onset or hospital admission are only
known to the nearest day, not hour or minute. Other events may be more
coarsely censored, for example to the nearest week or month.
censor_linelist()
converts the exact double point precision event
<Date>
to the time interval
specified.
Depending on the interval
specified, the date columns will be returned
as different objects. Here is a list of the valid input interval
and the
resulting class of the date column.
integer
-> <grates_period>
(see grates::as_period()
)
"daily"
-> <Date>
(see Date)
"weekly"
-> <grates_isoweek>
(see grates::as_isoweek()
)
"epiweek"
-> <grates_epiweek>
(see grates::as_epiweek()
)
"monthly"
-> <grates_yearmonth>
(see grates::as_yearmonth()
)
"yearly"
-> <grates_year>
(see grates::as_year()
)
A line list <data.frame>
.
set.seed(1)
linelist <- sim_linelist()
linelist_cens <- censor_linelist(linelist, interval = "daily")
# censor to a 3-day period
linelist_cens <- censor_linelist(linelist, interval = 3)
# no reporting of events on weekends
linelist_cens <- censor_linelist(
linelist,
interval = "daily",
reporting_artefact = "weekend_effects"
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.