## Example plot at NUTS0 level (country level)
# Simulated data trade in European countries
data("datatrade_EU")
# Mean of internal production for each country
library(dplyr)
data_plot <- datatrade_EU$internal_production %>%
group_by(reporter) %>%
summarise(mean_value = mean(value))
head(data_plot)
#Plot
pl <- plot_nuts(data = data_plot,
nuts_col = "reporter",
values_col = "mean_value",
nuts_level = 0)
pl
## Example plot at NUTS1 level (codes extracted from 'giscoR' package)
library(dplyr)
library(giscoR)
data_plot <- gisco_get_nuts(nuts_level=1) %>%
select(NUTS_ID) %>%
# simulate values for each NUTS1
mutate(values = abs(rnorm(nrow(.), 0, 1000)))
#Plot
pl <- plot_nuts(data = data_plot,
nuts_col = "NUTS_ID",
values_col = "values",
nuts_level = 1,
colors = c("white", "lightblue", "darkblue"),
title = "NUTS1",
legend_title = "units")
# Changing colors and adding other ggplot2 options
library(ggplot2)
pl +
xlim(-40, 50) + ylim(20, 70) +
theme_bw()
Run the code above in your browser using DataLab