mutate.incidence2 {incidence2} | R Documentation |
Create, modify, and delete incidence2 columns
Description
Method for dplyr::mutate that implicitly accounts for the inherent grouping structure of incidence2 objects.
Usage
## S3 method for class 'incidence2'
mutate(
.data,
...,
.by,
.keep = c("all", "used", "unused", "none"),
.before = NULL,
.after = NULL
)
Arguments
.data |
An incidence2 object. |
... |
< The value can be:
|
.by |
Not used as grouping structure implicit. |
.keep |
Control which columns from
|
.before , .after |
< |
Value
A modified incidence2 object if the necessary invariants are preserved, otherwise a tibble.
See Also
dplyr::mutate for the underlying generic.
Examples
if (requireNamespace("outbreaks", quietly = TRUE) && requireNamespace("ggplot2", quietly = TRUE)) {
data(ebola_sim_clean, package = "outbreaks")
ebola_sim_clean$linelist |>
subset(!is.na(hospital)) |>
incidence_(date_of_onset, hospital, interval = "isoweek") |>
mutate(ave = data.table::frollmean(count, n = 3L, align = "right")) |>
plot(border_colour = "white", angle = 45) +
ggplot2::geom_line(ggplot2::aes(x = date_index, y = ave))
}