rstudio – Building a heat world map in R Studio

I’m trying to build a world heat map in RStudio and I’m stumped as to why it looked this: enter image description here

My data is super simple: enter image description here

Why is it not showing a normal map? Furthermore, the UK has the highest number, but it is grey?!

Please advise. Thanks

data <- data.frame(
  country = c("UK", "Ghana", "USA", "Thailand", "Columbia", "Brazil"),
  value = c(12, 2, 1, 2, 1, 1)
)

world <- map_data("world")
data <- merge(world, data, by.x = "region", by.y = "country")

ggplot(data, aes(x = long, y = lat, group = group)) +
  geom_polygon(aes(fill = value), color = "grey") +
  scale_fill_gradient(low = "blue", high = "red") +
  theme_void()

I’ve tried various different packages but haven’t been able to solve the problem.

Read more here: Source link