The Respiratory viruses weekly repository contains weekly summaries of the erviss data for Influenza-Like Illness (ILI) and Acute Respiratory Infection (ARI).
This vignette shows how to use (some of) this data through the
diseasystore
package.
First, it is a good idea to clone the repository locally and store that location as an option for the package.
# First we set the path we want to use as an option
options(
"diseasystore.DiseasystoreEcdcRespiratoryViruses.source_conn" =
file.path("local", "path")
)
# Ensure folder exists
source_conn <- diseasyoption("source_conn", "DiseasystoreEcdcRespiratoryViruses")
if (!dir.exists(source_conn)) {
dir.create(source_conn, recursive = TRUE, showWarnings = FALSE)
}
# Clone the repository
system2(
"git",
args = c(
paste("-C", source_conn),
"clone https://github.com/EU-ECDC/Respiratory_viruses_weekly_data"
),
stdout = TRUE
)
The diseasystores
require a database to store its
features in. These should be configured before use and can be stored in
the packages options.
# We define target_conn as a function that opens a DBIconnection to the DB
target_conn <- \() DBI::dbConnect(RSQLite::SQLite())
options(
"diseasystore.DiseasystoreEcdcRespiratoryViruses.target_conn" = target_conn
)
Once the files are downloaded and the target database is configured,
we can initialize the diseasystore
that uses the ECDC
Respiratory Viruses Weekly data.
Once configured such, we can use the feature store directly to get data.
# We can see all the available features in the feature store
ds$available_features
#> [1] "iliari_rates" "infection_type" "age_group"
If you have locally cloned the repository, you may consider pulling
data from the repository manually and disabling automatic pulls.
Otherwise, the diseasystore
will check for updates every
time you request a feature.
# Manually update the repository
system2(
"git",
args = paste("-C", diseasyoption("source_conn", "DiseasystoreEcdcRespiratoryViruses")),
stdout = TRUE
)
# Disable automatic pulls
options("diseasystore.DiseasystoreEcdcRespiratoryViruses.pull" = FALSE)
# And then retrieve a feature from the feature store
ds$get_feature(feature = "iliari_rates",
start_date = as.Date("2023-01-01"),
end_date = as.Date("2023-03-01"))
#> # Source: table<`dbplyr_kARVMuOYeV`> [?? x 6]
#> # Database: sqlite 3.46.0 []
#> key_location age_group infection_type rate valid_from valid_until
#> <chr> <chr> <chr> <dbl> <dbl> <dbl>
#> 1 Austria <NA> ILI 2072. 19387 19394
#> 2 Austria <NA> ILI 2140. 19380 19387
#> 3 Austria <NA> ILI 2160. 19394 19401
#> 4 Austria <NA> ILI 2411. 19373 19380
#> 5 Austria <NA> ILI 2469. 19401 19408
#> # ℹ more rows