我有两个包含三个变量的数据集。我想在世界地图上将其中一个显示为热图,两个显示为饼图。
我使用了下面的代码,但出现了错误。我想知道如何解决它。
library(ggplot2)
library(scatterpie)
world_map <- map_data("world")
df <- data.frame(Country = c("USA", "Canada", "Mexico"),
Cases = c(10, 20, 30))
df_piechart <- data.frame(long = c(-95, -110, -75),
lat = c(37, 60, 20),
size = c(5, 10, 15),
Group1 = c(20, 30, 50),
Group2 = c(30, 40, 30))
ggplot() +
geom_map(dat = world_map, map = world_map, aes(map_id = region), color = "white", fill = "#d3d4d3", linewidth = 0.5, alpha=0.4 ) +
geom_map(dat = df, map = world_map, aes(map_id = Country, fill = …Run Code Online (Sandbox Code Playgroud)