The DiseasyObservables module is responsible for interfacing with the available diseasystores and provide
disease data to the models.
The module primarily acts as a convenience wrapper around the diseasystores. The observables and stratifications
will therefore depend on the data made available by the diseasystores.
See vignette("diseasy-observables")
Value
A new instance of the DiseasyBaseModule R6 class.
Super class
diseasy::DiseasyBaseModule -> DiseasyObservables
Active bindings
diseasystore(
character)
The set diseasystore to get DiseasyObservables for. Read-only.start_date(
Date)
Study period start. Read only.end_date(
Date)
Study period end. Read only.last_queryable_date(
Date)
The latest date that can be queried. Read-only.ds(
Diseasystore*)
The currently loaded diseasystore which provides the features. Read-only.available_observables(
character)
The currently available observables in the loaded diseasystore. Read-only.available_stratifications(
character)
The currently available stratifications in the loaded diseasystore. Read-only.slice_ts(
Dateorcharacter)
Date or timestamp (parsable byas.POSIXct) to slice the (time-versioned) data on. Read only.conn(
DBIConnection)
A database connection. Read only.
Methods
Method new()
Creates a new instance of the DiseasyObservables R6 class.
Usage
DiseasyObservables$new(
diseasystore = NULL,
start_date = NULL,
end_date = NULL,
last_queryable_date = NULL,
conn = NULL,
slice_ts = NULL,
...
)Arguments
diseasystore(
character)
A character string that controls which feature store to get data from.start_date(
Date)
Study period start. Used as default values forget_observation.end_date(
Date)
Study period end. Used as default values forget_observation.last_queryable_date(
Date)
Enforce a limit on data that can be pulled (not after this date).conn(
DBIConnection)
A database connection.slice_ts(
Dateorcharacter)
Date or timestamp (parsable byas.POSIXct) to slice the (time-versioned) data on....Parameters sent to
DiseasyBaseModuleR6 constructor.
Returns
A new instance of the DiseasyBaseModule R6 class.
Method get_observation()
Retrieve an "observable" in the data set corresponding to the set diseasystore.
By default, the internal values for start_date and end_date are used to return data,
but these can be overwritten.
The results are cached for faster retrieval at subsequent calls.
Usage
DiseasyObservables$get_observation(
observable,
stratification = NULL,
start_date = self %.% start_date,
end_date = self %.% end_date
)Arguments
observable(
character)
The observable to provide data or prediction for.stratification(
list(quosures))
Default NULL. Userlang::quos(...)to specify stratification. If given, expressions in stratification evaluated to give the stratification level.start_date(
Date)
Study period start.end_date(
Date)
Study period end.
Examples
# Create observables module using the Google COVID-19 data
obs <- DiseasyObservables$new(diseasystore = "Google COVID-19",
conn = DBI::dbConnect(RSQLite::SQLite()))
# See available observables
print(obs$available_observables)
#> [1] "n_population" "n_hospital" "n_deaths" "n_positive" "n_icu"
#> [6] "n_ventilator"
print(obs$available_stratifications)
#> [1] "age_group" "country_id" "country" "region_id"
#> [5] "region" "subregion_id" "subregion" "min_temperature"
#> [9] "max_temperature"
# Get data for one observable
if (FALSE) { # \dontrun{
obs$get_observation("n_hospital",
start_date = as.Date("2020-03-01"),
end_date = as.Date("2020-03-05"))
} # }
rm(obs)
