我将使用 gapminder 数据作为示例。假设我创建了这个动画:
library(gapminder)
library(ggplot2)
theme_set(theme_bw())
p <- ggplot(gapminder, aes(gdpPercap, lifeExp, size = pop, color =
continent, frame = year)) +
geom_point() +
scale_x_log10()
library(gganimate)
gganimate(p)
gganimate(p, "output.gif")
Run Code Online (Sandbox Code Playgroud)
现在,我想访问构成 gif 的单个图像(帧)。有没有办法在 gganimate 中做到这一点,还是我需要使用动画包?
为了澄清这个问题,我将简要描述数据。
中的每一行data.frame都是一个观察值,各列代表与该观察值相关的变量,包括:观察到的个体,观察的时间,观察的位置等。我想排除/过滤少于5个个体观察。
换句话说,如果少于5行,其中personal = x,那么我想删除包含个别x的所有行,并将结果重新分配给new data.frame。我知道有些类似的蛮力技术names == unique(df$individualname),然后分别将这些名称细分,然后应用nrow以确定是否排除它们……但是必须有一种更好的方法。感谢您的帮助,对于R我还是很陌生。