Population density by NUTS 3 region - demo_r_d3dens

Data - Eurostat

unit

Code
demo_r_d3dens %>%
  left_join(unit, by = "unit") %>%
  group_by(unit, Unit) %>%
  summarise(Nobs = n()) %>%
  arrange(-Nobs) %>%
  {if (is_html_output()) print_table(.) else .}
unit Unit Nobs
PER_KM2 Persons per square kilometre 53537

geo

Code
demo_r_d3dens %>%
  left_join(geo, by = "geo") %>%
  group_by(geo, Geo) %>%
  summarise(Nobs = n()) %>%
  arrange(-Nobs) %>%
  {if (is_html_output()) datatable(., filter = 'top', rownames = F) else .}

NUTS 3 Density

Code
demo_r_d3dens %>%
  filter(nchar(geo) == 5,
         time == "2018") %>%
  select(geo, values) %>%
  left_join(geo, by = "geo") %>%
  right_join(europe_NUTS3, by = "geo") %>%
  filter(long >= -15, lat >= 33) %>%
  ggplot(., aes(x = long, y = lat, group = group, fill = values)) +
  geom_polygon() + coord_map() +
  scale_fill_viridis_c(na.value = "white",
                       direction = -1,
                       breaks = 1000*seq(0, 1000, 2),
                       values = c(0, 0.02, 0.04, 0.06, 0.08, 0.1, 1)) +
  theme_void() + theme(legend.position = c(0.25, 0.85)) + 
  labs(fill = "Density")

NUTS 3 Density

Code
demo_r_d3dens %>%
  filter(nchar(geo) == 5,
         time == "2018") %>%
  select(geo, values) %>%
  left_join(geo, by = "geo") %>%
  right_join(europe_NUTS3, by = "geo") %>%
  filter(long >= -15, lat >= 33) %>%
  ggplot(., aes(x = long, y = lat, group = group, fill = values)) +
  geom_polygon() + coord_map() +
  scale_fill_viridis_c(na.value = "white",
                       direction = -1,
                       breaks = 1000*seq(0, 1000, 2),
                       values = c(0, 0.01, 0.02, 0.03, 0.04, 0.05, 1)) +
  theme_void() + theme(legend.position = c(0.25, 0.85)) + 
  labs(fill = "Density")

NUTS 3 Density (Log)

Code
demo_r_d3dens %>%
  filter(nchar(geo) == 5,
         time == "2018") %>%
  select(geo, values) %>%
  left_join(geo, by = "geo") %>%
  right_join(europe_NUTS3, by = "geo") %>%
  filter(long >= -15, lat >= 33) %>%
  ggplot(., aes(x = long, y = lat, group = group, fill = values)) +
  geom_polygon() + coord_map() +
  scale_fill_viridis_c(na.value = "white",
                       breaks = c(1, 4, 10, 40, 100, 400, 1000, 4000, 8000),
                       values = c(0, 0.1, 0.2, 0.3, 0.4, 0.5, 1), 
                       trans = scales::pseudo_log_trans(sigma = 0.001)) +
  theme_void() + theme(legend.position = c(0.25, 0.85)) + 
  labs(fill = "Density")