如何解决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 举报,一经查实,本站将立刻删除。