The following code works for the specific dataset that is "world":
ggplot(data = world)
geom_sf(aes(fill = pop_est))
scale_fill_viridis_c(option = "plasma", trans = "sqrt")
I would like to replace "world" with my own dataset where I can see the SuPDem level across the map for each country.
My data set:
structure(list(Country = c("Albania", "Albania", "Albania", "Albania", "Albania", "Albania"), Year = 1998:2003, SupDem = c(0.956826521693282, 0.936230742033029, 0.903573815990819, 0.876945257628013, 0.856216104588584,0.807742885231119), Supdem_u95 = c(1.90310875913895, 1.85879856969654,1.78495639758744, 1.65257180642367, 1.56308076745783, 1.51389360690687), Supdem_l95 = c(0.034448436601662, 0.0443012513174743, 0.0257741517619924,0.0691486153748455, 0.187039084923293, 0.0595276656884577), Supdem_sd = c(0.472026289177333, 0.464124184907683, 0.441013943388078, 0.402542004940216, 0.348425295168507, 0.377196905776233), ISO3c = c("ALB", "ALB", "ALB", "ALB", "ALB","ALB"), v2x_regime = c(0, 0, 0, 0, 0, 0)), row.names = c(NA,6L), class = "data.frame")
CodePudding user response:
OP clarified in chat, we want to use the location data from the package rnaturalearth
and plot the SupDem
value for each country for the year 2020
.
library(dplyr)
plotdata <- dplyr::inner_join(world, filter(myData, Year == 2020), by = c("admin" = "Country"))
ggplot(data = plotdata)
geom_sf(aes(fill = SupDem))
scale_fill_viridis_c(option = "plasma", trans = "sqrt")