The hardware and bandwidth for this mirror is donated by dogado GmbH, the Webhosting and Full Service-Cloud Provider. Check out our Wordpress Tutorial.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]dogado.de.

diseasystore: ECDC Respiratory Viruses Weekly

library(diseasystore)

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(duckdb::duckdb())
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.

ds <- DiseasystoreEcdcRespiratoryViruses$new()

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"))
#> Note: method with signature 'DBIConnection#Id' chosen for function 'dbExistsTable',
#>  target signature 'duckdb_connection#Id'.
#>  "duckdb_connection#ANY" would also be valid
#> # Source:   table<dbplyr_Q1isPQAJ9Z> [?? x 6]
#> # Database: DuckDB v1.1.1 [B246705@Windows 10 x64:R 4.4.0/:memory:]
#>   key_location age_group infection_type  rate valid_from valid_until
#>   <chr>        <chr>     <chr>          <dbl> <date>     <date>     
#> 1 Austria      05-14     ILI            4752. 2023-02-27 2023-03-06 
#> 2 Austria      <NA>      ILI            3299. 2023-02-27 2023-03-06 
#> 3 Austria      00-04     ILI            7024. 2023-02-20 2023-02-27 
#> 4 Austria      05-14     ILI            1743. 2023-02-13 2023-02-20 
#> 5 Austria      05-14     ILI            1584. 2023-02-06 2023-02-13 
#> # ℹ more rows

These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.
Health stats visible at Monitor.