Package 'plotDK'

Title: Plot Summary Statistics as Choropleth Maps of Danish Administrative Areas
Description: Provides a ggplot2 front end to plot summary statistics on danish provinces, regions, municipalities, and zipcodes. The needed geoms of each of the four levels are inherent in the package, thus making these types of plots easy for the user. This is essentially an updated port of the previously available 'mapDK' package by Sebastian Barfort.
Authors: Kristian Stendorff Nielsen [aut, cre]
Maintainer: Kristian Stendorff Nielsen <[email protected]>
License: MIT + file LICENSE
Version: 0.1.0
Built: 2025-02-14 04:57:01 UTC
Source: https://github.com/kristiansn/plotdk

Help Index


Create Plot Data

Description

If data is provided, this functions attempts to merge the provided data with the geom-data inherent in the package on the chosen plotlevel. If no data is provided, only the geom-data for the chosen plotlevel is returned. This data is used to create the DK-plot.

Usage

create_plot_data(data, id, plotlevel, show_missing = FALSE, ...)

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.

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.

...

Further arguments to pass to merge_data

Value

A data.frame with either raw geom-data or geom-data merged with any data provided.


Municipality data with keys and polygon-geoms for municipalities of Denmark

Description

Municipality data with keys and polygon-geoms for municipalities of Denmark

Usage

municipality

Format

A data frame with 39,230 rows and 7 columns:

long

Longitude coordinates.

lat

Latitude coordinates.

order

Order of coordinates in geoms.

group

Geom groups.

id

Name of entity.

id_numeric

Number of entity.

hole

Indication of a geom hole.

Source

Statistics Denmark


Information of Valid Municipality Names and Numbers

Description

Information of Valid Municipality Names and Numbers

Usage

municipality_info

Format

A data frame with 99 rows and 2 columns:

municipality_names

Valid names of municipalities.

municipality_numbers

Valid numbers of municipalities.

Source

Statistics Denmark


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
)

Province data with keys and polygon-geoms for provinces of Denmark

Description

Province data with keys and polygon-geoms for provinces of Denmark

Usage

province

Format

A data frame with 4,083 rows og 7 columns:

long

Longitude coordinates.

lat

Latitude coordinates.

order

Order of coordinates in geoms.

group

Geom groups.

id

Name of entity.

id_numeric

Number of entity.

hole

Indication of a geom hole.

@source Statistics Denmark


Information of Valid Province Names and Numbers

Description

Information of Valid Province Names and Numbers

Usage

province_info

Format

A data frame with 11 rows and 2 columns:

province_names

Valid names of provinces.

province_numbers

Valid numbers of provinces.

Source

Statistics Denmark


Region data with keys and polygon-geoms for regions of Denmark

Description

Region data with keys and polygon-geoms for regions of Denmark

Usage

region

Format

A data frame with 32,522 rows and 7 columns:

long

Longitude coordinates.

lat

Latitude coordinates.

order

Order of coordinates in geoms.

group

Geom groups.

id

Name of entity.

id_numeric

Number of entity.

hole

Indication of a geom hole.

Source

Statistics Denmark


Information of Valid Region Names and Numbers

Description

Information of Valid Region Names and Numbers

Usage

region_info

Format

A data frame with 5 observations and 2 columns:

region_names

Valid names of regions.

region_numbers

Valid numbers of regions.

Source

Statistics Denmark


Information of Valid Zipcodes

Description

Information of Valid Zipcodes

Usage

zipcode_info

Format

A data frame with 598 rows and 1 column:

zipcode_numbers

Valid numbers of zipcodes.

Source

Statistics Denmark


Zipcode data with keys and polygon-geoms for zipcodes of Denmark

Description

Zipcode data with keys and polygon-geoms for zipcodes of Denmark

Usage

zipcodes

Format

A data frame with 49,322 rows and 7 columns:

long

Longitude coordinates.

lat

Latitude coordinates.

order

Order of coordinates in geoms.

group

Geom groups.

id

Name of entity.

id_numeric

Number of entity.

hole

Indication of a geom hole.

Source

Statistics Denmark