mutate.incidence2 | R Documentation |
Method for dplyr::mutate that implicitly accounts for the inherent grouping structure of incidence2 objects.
## S3 method for class 'incidence2'
mutate(
.data,
...,
.by,
.keep = c("all", "used", "unused", "none"),
.before = NULL,
.after = NULL
)
.data |
An incidence2 object. |
... |
< The value can be:
|
.by |
Not used as grouping structure implicit. |
.keep |
Control which columns from
|
.before , .after |
< |
A modified incidence2 object if the necessary invariants are preserved, otherwise a tibble.
dplyr::mutate for the underlying generic.
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))
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.