In this vignette, we provide more detailed information on the data
included in covidnor, and demonstrate how to extract the
data you need.
We have the following groups of Covid data, for certain combinations of time and location specifications.
There are two type of time granularity: day
(date) and week (isoyearweek) in the data. For
geo granularity, there are country
(nation), county (county)and municipality
(municip). Note that not all outcomes of interest have
municipality level data.
Population data has been attached to compute number of cases per 100.000 population for a certain location.
In this dataset we only provide total age groups and sex groups.
Cases are the PCR test confirmed Covid positive cases. We have the following variables:
cases_by_testdate_n,
cases_by_testdate_vs_pop_pr100000cases_by_regdate_n,
cases_by_regdate_vs_pop_pr100000Available for
Tests are the number of testing events. We have the following variables:
testevents_all_n, testevents_pos_n,
testevents_neg_ntestevents_pos_vs_all_pr100Available for
We provide two variables related to hospital admissions:
hospital_admissions_main_cause_n;icu_admissions_n.Available for
For vaccination we provide data for two dates: vaccination date and registration date. We have data on 4 doses. For each dose, we have the following (e.g. dose 1):
vax_dose_1_by_vaxdate_nvax_dose_1_by_regdate_nvax_dose_1_by_vaxdate_sum0_999999_nAvailable for
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
syntax for data filtering and subsetting.
The way we organize time and location codes is documented in more detail in another csverse package, cstidy. We highly recommend you read through this vignette!
granularity_time and
granularity_geoTo get weekly Covid cases and hospital admissions as main cause for Norway (nation):
# 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[1:6,]
#>          date location_name cases hospital_adm
#> 1: 2022-11-13         Norge   534           60
#> 2: 2022-11-06         Norge   876          174
#> 3: 2022-10-30         Norge   780          151
#> 4: 2022-10-23         Norge   561          120
#> 5: 2022-10-16         Norge   499          117
#> 6: 2022-10-09         Norge   511          101Get data for a certain date and location combination:
totaldata[date == '2021-12-10' & location_code %in% c('county_nor03', 'county_nor15'), 
          .(date, location_name, 
            cases = cases_by_testdate_n, 
            vax_1 = vax_dose_1_by_vaxdate_n, 
            vaxcum1 = vax_dose_1_by_vaxdate_sum0_999999_n)]
#>          date   location_name cases vax_1 vaxcum1
#> 1: 2021-12-10            Oslo  1134   131  541045
#> 2: 2021-12-10 Møre og Romsdal   105   103  210189Can also get data for a whole calendar month, such as April 2022,
totaldata[calyearmonth == '2022-M04' & location_code == 'county_nor03', 
          .(date, location_name, 
            cases = cases_by_testdate_n)]
#>           date location_name cases
#>  1: 2022-04-30          Oslo    35
#>  2: 2022-04-29          Oslo    49
#>  3: 2022-04-28          Oslo    54
#>  4: 2022-04-27          Oslo    57
#>  5: 2022-04-26          Oslo    57
#>  6: 2022-04-25          Oslo    65
#>  7: 2022-04-24          Oslo    37
#>  8: 2022-04-23          Oslo    54
#>  9: 2022-04-22          Oslo    90
#> 10: 2022-04-21          Oslo    92
#> 11: 2022-04-20          Oslo    84
#> 12: 2022-04-19          Oslo   172
#> 13: 2022-04-18          Oslo    92
#> 14: 2022-04-17          Oslo    55
#> 15: 2022-04-16          Oslo    53
#> 16: 2022-04-15          Oslo    60
#> 17: 2022-04-14          Oslo    50
#> 18: 2022-04-13          Oslo    94
#> 19: 2022-04-12          Oslo   102
#> 20: 2022-04-11          Oslo   134
#> 21: 2022-04-10          Oslo    65
#> 22: 2022-04-09          Oslo    86
#> 23: 2022-04-08          Oslo   125
#> 24: 2022-04-07          Oslo   132
#> 25: 2022-04-06          Oslo   187
#> 26: 2022-04-05          Oslo   197
#> 27: 2022-04-04          Oslo   231
#> 28: 2022-04-03          Oslo   126
#> 29: 2022-04-02          Oslo   133
#> 30: 2022-04-01          Oslo   210
#>           date location_name cases