Getting Started

This package has multiple use cases, though they all revolve around data from the Danish Web Address API. If the below examples are not enough, please do read through the other vignettes. First we need to load the package.

library(dawaR)
#> ## {dawaR} provides data from the Danish Agency of Climate Data
#> ## DAWA is scheduled to shut down on October 1, 2026.
#> ## Terms and conditions apply.
#> ## Read more at: https://dawadocs.dataforsyningen.dk/dok/om#vilkaar

Getting regional data for Denmark

To get a dataframe of all the regions in Denmark, you can use the get_data() function.

get_data("regioner")
#> Warning: DAWA is deprecated and is scheduled to shut down on October 1, 2026.
#> Functions that depend on the API will stop working after that date. See
#> https://dataforsyningen.dk/data/4924 for details.
#> ! You do not have access to api.dataforsyningen.dk.
#> Please check your connection settings.
#> NULL

This will return data on each of the five regions.

Using DAWA to crosstab municipalities and their regions.

The function get_data() fetches the data in json format and by default transforms it to a data.frame.

library(dawaR)
library(dplyr)

municipalities <- get_data("kommuner")

nordjylland <- municipalities |>
  filter(regionsnavn == "Region Nordjylland") |>
  pull(navn)
nordjylland
#>  [1] "Morsø"           "Thisted"         "Brønderslev"     "Frederikshavn"  
#>  [5] "Vesthimmerlands" "Læsø"            "Rebild"          "Mariagerfjord"  
#>  [9] "Jammerbugt"      "Aalborg"         "Hjørring"

Here we have extracted all the municipalities that are in “Region Nordjylland”. The same can be done for voting precincts or police regions. It can also be done for addresses and others. Look through the available sections with available_sections().

Using DAWA map data

The function get_map_data() fetches data in geojson format and transforms the geometries to {sf} polygons. These polygons can be drawn as nice maps with {ggplot2}.

library(dawaR)
library(ggplot2)

municipalities <- get_map_data("kommuner")
ggplot(municipalities, aes(fill = regionsnavn)) +
  geom_sf(color = "black") +
  labs(fill = "Region") +
  cowplot::theme_map()

For more information on how to plot maps with {dawaR} please consult vignette("printing_maps").