Updating the covid19swiss Dataset

While the CRAN version of the package is updated once every month or two, the Github (Dev) version is updating on a daily bases. The following options allow you to keep the data updated with the ones available on the Dev version:

The update_swiss_data function

The update_swiss_data function enables to keep the installed version updated with the data available on Github. The function compared between the dataset on the installed version and the ones on the Dev version:

library(covid19swiss)

update_swiss_data()

If no new data is available on the Dev version, the function will return the following message:

No updates are available

Once new data is available, the function will prompt the following question that enables the user to select whether to install the updates from the dev version:

Updates are available on the covid19swiss Dev version, do you want to update? n/Y

In order to make the new data available, you will have to restart your R session.

Note: As frequent changes may occur on the raw data structure (such as new fields, retroactive updates in the data, etc.), the Dev version dataset may change accordingly.

Reading the data from the CSV version

Alternatively, you can read and load the data directly from the package repository, using the csv version:

swiss_df <- refresh_covid19swiss()

head(swiss_df)
#>         date location         location_type location_code location_code_type
#> 1 2020-01-24       GE Canton of Switzerland         CH.GE         gn_a1_code
#> 2 2020-01-24       GE Canton of Switzerland         CH.GE         gn_a1_code
#> 3 2020-01-24       GE Canton of Switzerland         CH.GE         gn_a1_code
#> 4 2020-01-24       GE Canton of Switzerland         CH.GE         gn_a1_code
#> 5 2020-01-24       GE Canton of Switzerland         CH.GE         gn_a1_code
#> 6 2020-01-24       GE Canton of Switzerland         CH.GE         gn_a1_code
#>      data_type value
#> 1 tested_total     4
#> 2  cases_total    NA
#> 3     hosp_new    NA
#> 4 hosp_current    NA
#> 5  icu_current    NA
#> 6 vent_current    NA

The main difference between the first method (the update_swiss_data function) and the second method (reading a CSV format of the data) is that on the first method the data will be available on future sessions. On the other hand, on the second method (with the refresh_covid19swiss function), the data is loaded as object to the environment.