knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)

fhidata provides structural data for Norway.

Please see https://folkehelseinstituttet.github.io/fhidata/reference/index.html for a quick overview of all available datasets and functions.

You can find out what version of fhidata you have installed by running the following commands:

library(fhidata)
library(data.table)

granularity_geo

The underlying foundation of the fhidata package is the strict categorization of location_code into granularity_geo. The concept is that a person should (generally) have data for all values of location_code for each granularity_geo that they are interested in.

# All the available values of granularity_geo
unique(fhidata::norway_locations_names()$granularity_geo)

So if a person is interested in doing analyses for granularity_geo=="county" then it is expected that a person has data for all of the following values of location_code

# All the available values location_code for granularity_geo=="county"
fhidata::norway_locations_names()[granularity_geo=="county"]$location_code

This is the reason why there are three "similar" values for

i.e. A person may want to use county-level data, but not want to include counties/municipalities that are not on mainland Norway.

Accessing Norwegian data via helper functions

It is recommended to access Norwegian population and location datasets via helper functions.

Norwegian locations

Redistricting is a common feature of the present Norwegian political climate. It is therefore important that our datasets can handle this. It is therefore recommended that a person set their desired year of redistricting (currently only 2020 is available) before using Norwegian data from this package. It is also possible to customize the desired border on a per-function basis using the border argument.

fhidata::set_config(border = 2020)

When using historical data, it is important to map the old/original location_code to the current/desired location_code.

fhidata::norway_locations_redistricting()

It is also important to understand the hierarchy of Norwegian locations, so that you can aggregate your own data up to different levels of granularity_geo.

fhidata::norway_locations_hierarchy(from = "wardoslo", to="municip")
fhidata::norway_locations_hierarchy(from = "municip", to="baregion")
fhidata::norway_locations_hierarchy(from = "county", to="faregion")

When creating a skeleton of a dataset, it is important to know all of the values of location_code within your desired granularity_geo.

fhidata::norway_locations_names()[granularity_geo %in% c("county", "notmainlandcounty","missingcounty")]$location_code

Finally, for publication purposes it is important to have a) names of the locations, and b) the correct ordering of the locations.

fhidata::norway_locations_names()

Norwegian population

The raw population datasets provide 1-year age groups, however, frequently the user is interested in custom age groups. The helper functions easily facilitate this need.

We provide data by age.

fhidata::norway_population_by_age_cats(cats = list(c(1:10), c(11:20)))
fhidata::norway_population_by_age_cats(cats = list("one to ten" = c(1:10), "eleven to twenty" = c(11:20)))
fhidata::norway_population_by_age_cats(cats = list(c(1:10), c(11:20), "21+"=c(21:200)))

And also data by age and sex.

fhidata::norway_population_by_age_sex_cats(cats = list(c(1:10), c(11:20)))
fhidata::norway_population_by_age_sex_cats(cats = list("one to ten" = c(1:10), "eleven to twenty" = c(11:20)))
fhidata::norway_population_by_age_sex_cats(cats = list(c(1:10), c(11:20), "21+"=c(21:200)))


folkehelseinstituttet/fhidata documentation built on June 3, 2022, 2:49 p.m.