I am trying to make a simple chloropleth map in r. While I can create the map, China does not show up at all, leaving a giant hole in the map. I have checked that China is in the data, so I am not sure what is going on. here is my code:
library(tidyverse)
library(maps)
## load data ----
data(country.map, package = "choroplethrMaps")
co2 <- read.csv("https://raw.githubusercontent.com/acircleda/tmp/master/food emissions.csv") %>%
mutate(region = tolower(country))
data<-co2 %>%
left_join(country.map, by="region") %>%
group_by(region) %>% mutate(
c02sum = sum(co2_emmission)
)
ggplot(data, aes(long, lat, group = group))+
geom_polygon(aes(fill = c02sum), color = "white", na="grey80")+
scale_fill_viridis_c(option = "C")
##no china
china<-data %>% filter(region == "china") ##china is in the data

The problem is your data join. What you actually want, is a right_join. NAs can be coloured in your scale_fill functions with na.value = .
library(tidyverse)
library(maps)
## load data ----
data(country.map, package = "choroplethrMaps")
co2 <- read_csv('your.csv')%>%
mutate(region = tolower(country))
data <- co2 %>%
right_join(country.map, by="region") %>% #critical
group_by(region)
ggplot(data, aes(long, lat, group = group))+
geom_polygon(aes(fill = co2_emmission), na.rm ="grey80") +
scale_fill_continuous(na.value = 'grey')

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With