In this vignette, we provide more detailed information on the data included in respiranor
, and demonstrate how to extract the data you need.
Covid data outcomes
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
Cases are the PCR test confirmed Covid positive cases. We have the following variables:
- number of cases (counts, per 100.000 population) by the date of PCR test,
cases_by_testdate_n
,cases_by_testdate_vs_pop_pr100000
- number of cases (counts, per 100.000 population) by the date of registration,
cases_by_regdate_n
,cases_by_regdate_vs_pop_pr100000
Available for
- granularity_time: date, isoyearweek
- granularity_geo: nation, county, municip (only for registration date)
Tests
Tests are the number of testing events. We have the following variables:
- number of testing events (all, positive, negative),
testevents_all_n
,testevents_pos_n
,testevents_neg_n
- percentage of testing events that are positive,
testevents_pos_vs_all_pr100
Available for
- granularity_time: date, isoyearweek
- granularity_geo: nation
Hospital admission
We provide two variables related to hospital admissions:
- admission due to Covid as main cause,
hospital_admissions_main_cause_n
; - ICU admission,
icu_admissions_n
.
Available for
- granularity_time: date, isoyearweek
- granularity_geo: nation
Vaccination
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):
- number of vaccinations delivered on the date,
vax_dose_1_by_vaxdate_n
- number of vaccinations registered in SYSVAK,
vax_dose_1_by_regdate_n
- cumulative number of vaccinations delivered by the date,
vax_dose_1_by_vaxdate_sum0_999999_n
Available for
- granularity_time: date, isoyearweek
- granularity_geo: nation, county, municip (only for registration date)
Subsetting data
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!
Based on granularity_time
and granularity_geo
To get weekly Covid cases and hospital admissions as main cause for Norway (nation):
# load total data (419k rows)
totaldata <- respiranor::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 101
Based on specific dates and locations
Get 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 210189
Can 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