plotDK {plotDK}R Documentation

Generate choropleth maps of Danish Municipalities, Regions, Provinces and Zip-areas

Description

Draws a map that highligths any value of interest across either danish municipalities, regions, provinces or zip-codes. This is essentially a ggplot2-wrapper incorporating geoms of danish municipalities, regions, provinces and zipcodes. Therefore the output is compatible with further ggplot2 elements.

Usage

plotDK(
  data = NULL,
  id = NULL,
  value = NULL,
  plotlevel = "municipality",
  show_missing = FALSE,
  show_borders = TRUE,
  interactive = FALSE,
  titel = NULL
)

Arguments

data

A data.frame containing an ID-variable specifying either a municipality, region, province or zipcode (see id), as well as a value-variable containing any value to be plotted on the chosen level.

id

A character specifying the name of a column in data containing the ID on the chosen level.

For municipalities these variables can be either;

  • A character-variable with danish municipality names. For accepted values see municipality_info.

  • A numeric/integer-variable with official municipality numbers. For accepted values see municipality_info.

For regions these variables can either;

  • A character-variable with danish region names. For accepted values see region_info.

  • A numeric/integer-variable with danish region numbers. For accepted values see region_info.

For provinces these variables can be either;

  • A character-variable with danish province names. For accepted values see province_info.

  • A numeric/integer-variable with danish province numbers. For accepted values see province_info.

For zip-codes these variables can be;

  • A numeric/integer-variable with danish zip-codes. For accepted values see zipcode_info.

value

numeric-, factor- or character-variabel to be plotted on the map. Note that character-variables will be naively translated to factors behind the scenes. For full control over levels, pre-convert to a factor.

plotlevel

character, indicating which level to plot. Valid options are "municipality", "region", "province", and "zipcode".

show_missing

logical. Should levels not present in data or with NA-values be printed? This can be used to plot only a subset of entities.

show_borders

logical. Should geom borders be drawn?

interactive

logical. Should the plot be converted to an interactive plotly plot?

titel

character. Optional plot title.

Value

A ggplot object.

Examples


## Empty plot
plotDK()

province_data <- data.frame(
 province_name = c(
   "nordjylland", 
   "østjylland",
   "vestjylland", 
   "fyn", 
   "sydjylland", 
   "vest-ogsydsjælland",
   "østsjælland", 
   "københavnsomegn",
   "byenkøbenhavn", 
   "bornholm",
   "nordsjælland"
 ),
 value = 1:11, 
 stringsAsFactors = FALSE
)





[Package plotDK version 0.1.0 Index]