map_plot {DEplotting} | R Documentation |
Plot Regionalized Data on Maps of Germany
Description
Visualizes regional data by creating maps of Germany. Currently supports states (Länder), districts (Kreise, kreisfreie Städte), and municipalities (Gemeinde). Can be used to plot any lower level within a higher one, e.g. states within Germany or municipalities within a district.
Usage
map_plot(
data,
var,
map_section = "",
level = "",
add_labels,
year,
geo_year,
palette = ""
)
Arguments
data |
Data frame. The dataset containing the variable to be plotted. |
var |
Character. The name of the variable (column) in |
map_section |
Character vector of AGS codes or federal state shortcuts. Used to define the outer boundaries of the map. Shortcuts are available for Germany ("DE") and for each federal state (e.g., "BE" for Berlin). For other areas, providing an AGS code is necessary, which can be looked up using the |
level |
Character "land", "kreis", or "gemeinde". Used to define the inner boundaries, i.e. the areas which will be plotted within |
add_labels |
Logical. Whether to show numeric labels on the map. If TRUE, will not only fill each area specified in |
year |
Integer. Year of the data to be plotted. Will detect the respective column in |
geo_year |
Integer or "". Year of the geodata to use; defaults to "" for which the year provided in |
palette |
Character. Name of the color palette ("Red", "Blue", etc.). |
Value
A ggplot2 object visualizing the provided regional data. Can be further customized.
Examples
data <- nstudents2022 # provide the data you want to plot here
# Example: Plotting the number of students in Germany by state
map_plot(
data = data, # the dataset containing the variable to plot
var = "nStudents", # the variable to plot
map_section = "DE", # plot entire Germany
level = "land", # plot by state
add_labels = FALSE, # do not show labels
year = 2022, # year of the data
geo_year = "", # use the same year for geodata
palette = "red" # use red color palette
)