Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
Mauricio “Pachá” Vargas Sepúlveda
Blog with notes about R, Shiny, SQL, Python, Linux and C++. This blog is listed on R-Bloggers.
Categories
- Armadillo
- Arrow
- BibTeX
- Blogdown
- C++
- CRAN
- D3po
- DigitalOcean
- DuckDB
- Education
- GitHub
- Google Sheets
- Inkscape
- International Trade
- Interviews
- Kubernetes
- Latex
- Linear algebra
- Linear models
- Linux
- Manjaro
- Microsoft Excel
- NLP
- Non-English datasets
- OS X
- OpenBLAS
- Pelican
- Positron
- PostGIS
- PostgreSQL
- Python
- Quarto
- R
- R Packages
- R-Universe
- R4DS
- REST API
- RStudio
- RStudio Server
- Redatam
- Rick and Morty
- SPSS
- SQL
- Selenium
- Shiny
- Spreadsheets
- Stan
- Stata
- Statistics
- Tabler
- Tidyverse
- Ubuntu
- VSCode
- Windows
- Zotero
- cpp11
- cpp4r
- ggplot2
- golem
- plotnine
- purrr
- wbstats
Mauricio “Pachá” Vargas S.
August 28, 2025
Because of delays with my scholarship payment, if this post is useful to you I kindly ask a minimal donation on Buy Me a Coffee that shall be used to continue my Open Source efforts. If you need an R package or Shiny dashboard for your team, you can email me or inquiry on Fiverr. The full explanation is here: A Personal Message from an Open Source Contributor
Continuing with the previous blog question ‘how can you plot a map of the UK with ggplot2?’
I started working more on ukmaps for easy plotting of administrative and electoral areas.
You can install the development version of ukmaps (v0.0.2) with:
remotes::install_github("pachadotdev/ukmaps")
< section id="examples" class="level1">
Examples
< section id="yesno-map-of-london-administrative-areas" class="level2">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)
Country-level map of the UK
pal <- c("#165976", "#365158", "#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)
Which part of Barnet is Golders Green in?
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 improve the datasets soon to allow filtering by city and more.
I hope this is useful 🙂
Loading…
