---
title: "Updating the covid19swiss Dataset"
output: rmarkdown::html_vignette
vignette: >
  %\VignetteIndexEntry{Update the Dataset}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

```{r, include = FALSE}
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
library(covid19swiss)
```

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:

* Reinstall the dev package (if new data is available) by using the `update_swiss_data` function 
* Read directly from the package repo a csv format of the data with the `refresh_covid19swiss` function

### 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:

``` r 
library(covid19swiss)

update_swiss_data()
```

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

``` r
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:

``` r
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:

```{r}
swiss_df <- refresh_covid19swiss()

head(swiss_df)
```

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.




