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. It will be used to continue my open source efforts. The complete explanation is here: A personal message from an Open Source employee. If you need an R package or a shiny dashboard for your team, you can e -mail me or ask me Fiverr.
I have this question: How can you switch off a UK card with GGPLOT2?
The answer is that you must read a Geojson or equivalent file with the SF package and then the geom_sf() Function of GGPLOT2.
My apologies if my online search was not good, but all search engines in Canada got worse after Bill C-18 was accepted. I have found this Maintained by Martin Chorley, I thought the data lecture could be simplified, and so I started a small data package.
You can install the development version of Ukmaps such as SO to install V0.0.1:
remotes::install_github("pachadotdev/ukmaps")And here is a simple example of how to use it with DPLYR and GGPLOT2:
library(ukmaps)
library(dplyr)
library(ggplot2)
london_areas <- c(
"City of London", "Barking and Dagenham", "Barnet", "Bexley", "Brent", "Bromley",
"Camden", "Croydon", "Ealing", "Enfield", "Greenwich", "Hackney", "Hammersmith and Fulham",
"Haringey", "Harrow", "Havering", "Hillingdon", "Hounslow", "Islington",
"Kensington and Chelsea", "Kingston upon Thames", "Lambeth", "Lewisham", "Merton",
"Newham", "Redbridge", "Richmond upon Thames", "Southwark", "Sutton",
"Tower Hamlets", "Waltham Forest", "Wandsworth", "Westminster"
)
d <- administrative %>%
filter(country == "England") %>%
mutate(is_london = if_else(area_name %in% london_areas, "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 an administrative area of London?") +
labs(title = "Map of England with Administrative 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 #RBloggers


