如何使动画情节在到达最后一个动画步骤时停止回滚?

How to make an animated plot to stop rolling back when reaching the last animation step?

这是我制作的动画情节的可复制示例:

library(tidyverse)
library(gganimate)

data.1 <-read.csv(text = "
Year, value
1970,0
1980,1500
1990,2300
2000,4000
2010,4200
2020,6000
")
  
ggplot(data = data.1 %>% mutate(Year=as.numeric(Year),
                                  value=as.numeric(value)), 
       mapping = aes(x = Year, 
                     y = value)) +
    geom_line() +
    transition_reveal(Year) 

动画还可以,但是我想让它在可视化的最后一年停止而不是回滚。 transition_reveal 可以吗?

渲染 gif 时,您可以这样设置 loop = FALSE

animate(myplot, renderer = gifski_renderer(loop = FALSE))