knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "85%", dpi = 300, fig.align = "center" )
![License: GPL (>= 3)](https://img.shields.io/badge/license-GPL (>= 3)-blue.svg)
The purpose of voters
is to provide easy access to data on Danish polling stations.
The primary data is provided through Danmarks Adressers Web API (DAWA). DAWA is developed and run by the Danish Agency for Data Supply and Efficiency (SDFE). SDFE's terms of use apply.
Additional data is provided by the Danish Election Database.
Download data on Danish polling stations using the voters::getPS()
function:
library(voters)
df <- getPS() df
library(ggplot2) library(MetBrewer) pal <- met.brewer("Isfahan2", type = "discrete") df %>% ggplot(data = .) + geom_sf(aes(fill = regi), color = "grey90", size = .0000000001) + scale_fill_manual(values = pal, name = "") + theme_void()
As a default, data is downloaded as a spatial dataset of type "sf", "tibble"
:
class(df)
To download a non-spatial version simply use the spatial
argument:
df_raw <- getPS(spatial = FALSE) class(df_raw)
id
By default, getPS()
returns an ID variable (ps_id
). This provides a way to link the polling station data to election results from the Danish Election Database.
Note that as of November 18, 2021, the Danish Election Database has not been updated to match the updated polling stations provided by getPS()
. As a result, some stations remain without a valid ID:
table(is.na(df$ps_id))
Specify id = FALSE
to export data without the Danish Election Database ID.
You can install the development version from GitHub with:
if(!require("devtools")) install.packages("devtools") library(devtools) devtools::install_github("jvieroe/voters")
R
Core Team for developing and maintaining the languageAdd the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.