Skip to contents

This function returns a plot of the vaccine coverage or the cumulative coverage (if cumulative = TRUE). The return is a 2-axis ggplot2 element with the number of vaccines per date on the left axis and the coverage per date on the right axis. When a matching routine is performed, the left axis also accounts for the doses of the matched cohort.

Usage

plot_coverage(vaccineff_data, date_interval = NULL, cumulative = FALSE)

Arguments

vaccineff_data

Object of the class vaccineff_data with vaccineff data.

date_interval

If NULL, the function calculates the coverage interval based on the min() and max() of the vacc_date_col. It is also possible to pass a custom date interval to truncate or expand the date interval (see example).

cumulative

If TRUE, returns the cumulative number of doses over the time window.

Value

2-axis ggplot2 plot of vaccine coverage and daily doses.

Examples

# Load example data
data("cohortdata")

# Create `vaccineff_data`
vaccineff_data <- make_vaccineff_data(data_set = cohortdata,
  outcome_date_col = "death_date",
  censoring_date_col = "death_other_causes",
  vacc_date_col = "vaccine_date_2",
  vaccinated_status = "v",
  unvaccinated_status = "u",
  immunization_delay = 15,
  end_cohort = as.Date("2044-12-31"),
  match = TRUE,
  exact = c("age", "sex"),
  nearest = NULL
)
plot_coverage(vaccineff_data = vaccineff_data,
  date_interval = as.Date(c("2044-01-03", "2044-09-30")),
  cumulative = FALSE
)