R 出现后结束动画

R 出现后结束动画,r,gganimate,R,Gganimate,我用我的数据制作了一个动画,并设法为powerpoint演示文稿提供了一个良好的抓拍/分辨率 我希望条形图中的条形图出现,然后结束动画。我在gganimate中找不到使动画仅在一个方向上运行(仅显示)的正确设置 a好的,我自己找到的!可以使用过渡状态(wrap=FALSE)切换动画运行后的结束: a <- data.frame(group = c("sehr schlecht", "schlecht&

我用我的数据制作了一个动画,并设法为powerpoint演示文稿提供了一个良好的抓拍/分辨率

我希望条形图中的条形图出现,然后结束动画。我在gganimate中找不到使动画仅在一个方向上运行(仅显示)的正确设置


a好的,我自己找到的!可以使用过渡状态(wrap=FALSE)切换动画运行后的结束:

    a <- data.frame(group = c("sehr schlecht",
                          "schlecht",
                          "weder noch",
                          "gut",
                          "sehr gut"),
                values = c(0, 0, 0, 0, 0),
                frame = rep("a", 5))

b <- data.frame(group = c("sehr schlecht",
                          "schlecht",
                          "weder noch",
                          "gut",
                          "sehr gut"),
                values = c(20,
                          40,
                          20,
                          5,
                          15),
                frame = rep("b", 5))

graphdata <- rbind(a,b)  

p <- ggplot(graphdata, aes(x=group, y=values, fill=group)) + 
  geom_bar(stat='identity') +
  ylim(0, 100) +
  theme_bw() +
  theme(legend.title=element_blank()) +
  scale_x_discrete(name ="Anteil (%)", 
                   limits=c("sehr schlecht",
                            "schlecht",
                            "weder noch",
                            "gut",
                            "sehr gut")) +
  # gganimate specific bits:
  transition_states(
    frame,
    transition_length = 2,
    state_length = 1
  ) +
  ease_aes('sine-in-out')

options(gganimate.dev_args = list(width = 800, height = 600, res = 150))
                           
animate(p + enter_appear(),
  renderer = av_renderer()
)
  # gganimate specific bits:
  transition_states(
    frame,
    transition_length = 2,
    state_length = 1,
    wrap = FALSE
  ) +
  ease_aes('sine-in-out')