View source: R/cases_within_radius.R
cases_within_radius | R Documentation |
Based on the postcodes4_afstanden data set, this function determines the specified minimum number of cases within a certain radius.
cases_within_radius(
data,
radius_km = 10,
minimum_cases = 10,
column_count = NULL,
...
)
data |
data set containing a column 'postcode' |
radius_km |
radius in kilometres from each zip code. The search diameter is twice this number (since zip codes e.g. to the west and to the east are searched). |
minimum_cases |
minimum number of cases to search for |
column_count |
column name in |
... |
ignored, allows for future extensions |
This function adds two columns ("cases_within_radius"
<dbl>
and "minimum_met"
<lgl>
) to the input data.
library(dplyr, warn.conflicts = FALSE)
postcodes_friesland <- geo_postcodes4 |>
filter_geolocation(provincie == "Friesland") |>
pull(postcode)
# example with Norovirus cases:
noro <- data.frame(postcode = postcodes_friesland,
n = floor(runif(length(postcodes_friesland),
min = 0, max = 3)))
head(noro)
radial_check <- cases_within_radius(noro, radius_km = 10, minimum_cases = 10)
head(radial_check)
# dplyr group support:
mdro <- data.frame(type = rep(c("ESBL", "MRSA", "VRE"), 20),
pc4 = postcodes_friesland[1:20],
n = floor(runif(60, min = 0, max = 3)))
mdro |>
group_by(type) |>
cases_within_radius()
# plotting support:
if (require("certeplot2")) {
radial_check |>
add_map() |>
filter_geolocation(provincie == "Friesland") |>
plot2(category = cases_within_radius,
category.title = "Cases",
datalabels = FALSE,
colour_fill = "viridis")
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.