Do you want to share your content on R-bloggers? Click here if you have a blog, or here If you don’t.
Due to delays with my stock market payment, if this message is useful for you, I kindly request a minimal donation Buy a coffee for me That will be used to continue my open source efforts. If you need an R package or a shiny dashboard for your team, you can e -mail me or ask me Fiverr. The complete explanation is here: A personal message from an Open Source employee
Continue with the previous blog question “How can you plan a map of the UK with GGPLOT2?”
I started working more on Ukmaps for simple planning of administrative and election areas.
You can install the development version of UKMAPS (V0.0.2) with:
remotes::install_github("pachadotdev/ukmaps")Yes/no map of London administrative areas
library(ukmaps)
library(dplyr)
library(ggplot2)
d <- administrative %>%
mutate(is_london = if_else(region == "London", "Yes", "No"))
pal <- c("#165976", "#d04e66")
ggplot(d) +
geom_sf(aes(fill = is_london, geometry = geometry), color = "white") +
scale_fill_manual(values = pal, name = "Is this London?") +
labs(title = "Map of England with Administrative Boundaries") +
theme_minimal(base_size = 13)Land level map of the UK
pal <- c("#165976", "#d04e66", "#ffd613")
# country() aggregates the map to country level
ggplot(country()) +
geom_sf(aes(fill = country, geometry = geometry), color = "white") +
scale_fill_manual(values = pal, name = "Country") +
labs(title = "Map of England with Country Boundaries") +
theme_minimal(base_size = 13)![]()
In which part of Barnet is Golders Green?
d <- electoral %>%
filter(lad_name == "Barnet" & boundary_type == "ward") %>%
mutate(is_golders_green = if_else(area_name == "Golders Green", "Yes", "No"))
pal <- c("#165976", "#d04e66")
ggplot(d) +
geom_sf(aes(fill = is_golders_green, geometry = geometry), color = "white") +
scale_fill_manual(values = pal, name = "Is this Golders Green?") +
labs(title = "Map of Barnet (London) with Electoral Boundaries") +
theme_minimal(base_size = 13)![]()
I will soon improve the data sets to make filtering per city and more possible.
I hope this is useful 🙂
Related
#cards #plotting #GGPLOT2 #part #RBloggers


