knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-",
  out.width = "85%",
  dpi = 300,
  fig.align = "center"
)

voters

CodeFactor R-CMD-check ![License: GPL (>= 3)](https://img.shields.io/badge/license-GPL (>= 3)-blue.svg) Codecov test coverage

Introduction

The purpose of voters is to provide easy access to data on Danish polling stations.

Terms of use

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.

Usage

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()

Output specification

Data format

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)

Polling station 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.

Installation

You can install the development version from GitHub with:

if(!require("devtools")) install.packages("devtools")
library(devtools)
devtools::install_github("jvieroe/voters")

Acknowledgements



jvieroe/voters documentation built on Feb. 5, 2022, 5:22 p.m.