ggplot2绘制国家/地区数据导致“节点堆栈溢出错误”

问题描述

我正在尝试重现并执行本博客文章(https://www.r-bloggers.com/2020/09/visualization-of-covid-19-cases-in-arkansas/)产生的R脚本。

一切运行平稳,但是当到达最后两个有关使用ggplot和gganimate创建最终动画的指令时,我遇到了“节点堆栈溢出错误”,这是我使用R迄今为止从未遇到过的问题。

 <- ggplot(temp_sf) +
  geom_sf(aes(fill = roll_capita),size = 0.25) +
  scale_fill_viridis(
    name = "7-day rolling cases: ",trans = "log10",option = "plasma",) +
  ggthemes::theme_map() +
  theme(legend.position = "bottom",legend.justification = "center") +
  labs(
    title = paste0("Arkansas 7-day rolling average of new COVID cases per ",scales::comma(per_capita)," residents"),subtitle = "Date: {frame_time}",caption = paste0("Image generated: ",Sys.time(),"\n","Data source: https://github.com/CSSEGISandData/COVID-19","COVID-19 Data Repository by CSSE at Johns Hopkins University")
  ) +
  transition_time(date)

anim <- animate(
  p,nframes = days + 10 + 30,fps = 5,start_pause = 10,end_pause = 30,res = 96,width = 600,height = 600,units = "px"
)

ggplot调用中涉及的小标题(即temp_sf)具有17025个观察值和5个变量,并使用以下指令创建:

temp_sf <- tigris::counties(cb = T,resolution = "500k") %>%
  mutate(GEOID = as.numeric(GEOID)) %>%
  inner_join(temp %>% select(FIPS,roll_cases,roll_capita,date),by = c("GEOID" = "FIPS")) %>%
  select(GEOID,date,geometry)

您知道为什么会发生这种错误吗?是与执行代码的环境(旧的Surface Pro 3)有关还是编程错误?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...