---
title: "Introduction to covidnor"
output: rmarkdown::html_vignette
vignette: >
  %\VignetteIndexEntry{Introduction to covidnor}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

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


[covidnor](https://www.csids.no/covidnor/) cleans and merges the publicly available datasets on COVID-19 in Norway into analysis-ready datasets. 

The following data are provided in this package: 

* case numbers
* ICU/hospital admissions
* testing
* vaccinations

The overall data is stored as `total`, and has 419k rows. More information on what variables and specifications are available, and how to extract specifications you want can be found [here](https://www.csids.no/covidnor/articles/data_details.html). 


## Getting started

Instead of working directly on `total` data, you might want to use a certain combination of **time, location, outcome**. We recommend using the [data.table](https://CRAN.R-project.org/package=data.table) syntax for data filtering and subsetting.

For example, to get **weekly** Covid cases and hospital admissions as main cause for Norway:

```{r}
# load total data (419k rows)
totaldata <- covidnor::total_b2020

# get weekly cases (confirmed) and hospitalisation for Norway
case_hosp <- totaldata[granularity_time == 'isoyearweek' &
                     granularity_geo == 'nation',
                   .(date, 
                     location_name, 
                     cases = cases_by_testdate_n, 
                     hospital_adm = hospital_admissions_main_cause_n)]
case_hosp
```


For more details, please refer to the [vignette](https://www.csids.no/covidnor/articles/data_details.html) and [data documentation](https://www.csids.no/covidnor/reference/total_b2020.html).

Several of CSIDS packages ([csstyle](https://www.csids.no/csstyle/index.html),  [csalert](https://www.csids.no/csalert/index.html)) make use of `covidnor` data. You can read the following documentation to find out more, 

* [Epicurves](https://www.csids.no/csstyle/articles/epicurves.html) in `cstyle`,
* [Short term trend for COVID cases](https://www.csids.no/csalert/articles/short_term_trend.html) in `csalert`.


### Background 

This package curates publicly available COVID-19 data in Norway between 2020-04-24 to 2022-11-14. The original data repository (`surveillance_data`) which automatically published machine-friendly COVID-19 data updates on weekdays at 13:15 can be accessed [here](https://github.com/folkehelseinstituttet/surveillance_data). The original repository was archived by Sykdomspulsen team at the Norwegian Institute of Public Health due to lack of funding. 
