format_data: Format epidemiological data

View source: R/format_data.R

format_dataR Documentation

Format epidemiological data

Description

The purpose of this function is to format any data input to be used directly in the pandemic_model function as the Y argument.

Usage

format_data(
  s_date,
  e_date,
  cases = NULL,
  n_cases = NULL,
  deaths = NULL,
  n_deaths = NULL,
  name,
  pop
)

Arguments

s_date

start date of the time series. It should be in the YYYY-MM-DD format.

e_date

end date of the time series. It should be in the YYYY-MM-DD format.

cases

numeric vector containing the cumulative case counts per day from the start date until the end date.

n_cases

numeric vector containing the new case counts per day from the start date until the end date.

deaths

numeric vector containing the cumulative death counts per day from the start date until the end date.

n_deaths

numeric vector containing the new death counts per day from the start date until the end date.

name

string specifying the location name.

pop

numeric object that contains the population size of the given location.

Details

This function requires that at least one of the data inputs cases, n_cases, deaths, n_deaths is provided. If only cumulative data was inserted, format_data will automatically calculate the new case counts. On the contrary, if only new case counts were provided, then the cumulative counts will be calculated. Check covid19BH for a complete example on how to use this function.

Value

An object of S3 class pandemicData. It is a list with 3 items:

data:

data frame with the number of cumulative cases, new cases or/and cumulative deaths and new deaths for each date, from s_date up to the e_date in the specified region.

name:

string with the location name.

population:

numeric object that contains the population size of the given location.

See Also

covid19BH

Examples

## Not run: 

#illustrative epidemiological data
cases <- c(0,1,4,7,10,19)
n_cases <- c(cases[1], diff(cases))

#format data to use in pandemic_model
data <- format_data(s_date = "2021-01-01", e_date = "2021-01-06",
                    cases = cases, n_cases = n_cases,
                    name = "Example", pop = 1234)

data
plot(data)

## End(Not run)


PandemicLP documentation built on March 18, 2022, 6:22 p.m.