Help with a ggplot map, please!!

Hi, please can someone tell me why italy and spain are not being produced in all 4 maps ???

20358991_POLI1029_2122

#Clear Objects
rm(list = ls())

#Set Working Directory
setwd("C:/Users/roger/OneDrive - The University of Nottingham/Political Data/v14")

#Install Packages (un-comment if needed)
#install.packages("tidyverse")
#install.packages("patchwork")

#Load Packages
library(tidyverse)
library(patchwork)

#Read Data Set
full_covid_data <- read.csv("JHU-UN-IPU_Covid.csv")

#Load in our shapefile
europe_map <- map_data("world", xlim = c(0, 25),ylim = c(40, 60), expand = FALSE)

map <- ggplot() + geom_polygon(data = europe_map, color = "black", size = 0.25,
aes(x = long, y = lat, group = group))

#Merge variables of interest
covid <- left_join(europe_map, full_covid_data, by = c(region = "country"))

#Filter Data Set
covidmap <- filter(covid, total_cases !=0, monthlyDateN == c(2020.12,2021.03,2021.06,2021.09))

#maps
covidmap_vaccination <- ggplot() + geom_polygon(data = covidmap, color = "black", size = 0.25,
aes(x = long, y = lat, group = group,
fill = (((people_fully_vaccinated - people_partially_vaccinated)+people_partially_vaccinated)/population)*100))

covidmap_vaccination + geom_path() + scale_fill_gradient(low = "cyan", high = "darkblue") +
theme(axis.text.x = element_blank(), axis.text.y = element_blank(), axis.ticks = element_blank()) +
labs(title = "January", fill = "vaccination doses administered", x = "", y = "") +
theme(panel.background = element_blank()) + facet_wrap(~monthlyDateN)

Without some sample data it is difficult to answer.

A handy way to supply sample data is to use the dput() function. See ?dput. If you have a very large data set then something like head(dput(myfile), 100) will likely supply enough data for us to work with.

I'm not familiar with the patchwork package. In my experience with geospatial stuff in R I found this to be very helpful.

https://r-spatial.org/r/2018/10/25/ggplot2-sf.html

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.