小编And*_*ade的帖子

如何保存使用 gganimate 包创建的 gif 帧

我将使用 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 中做到这一点,还是我需要使用动画包?

r gganimate

6
推荐指数
1
解决办法
5142
查看次数

如何从数据框中删除少于5个观察值的个体

为了澄清这个问题,我将简要描述数据。

中的每一行data.frame都是一个观察值,各列代表与该观察值相关的变量,包括:观察到的个体,观察的时间,观察的位置等。我想排除/过滤少于5个个体观察。

换句话说,如果少于5行,其中personal = x,那么我想删除包含个别x的所有行,并将结果重新分配给new data.frame。我知道有些类似的蛮力技​​术names == unique(df$individualname),然后分别将这些名称细分,然后应用nrow以确定是否排除它们……但是必须有一种更好的方法。感谢您的帮助,对于R我还是很陌生。

r count filter dataframe

4
推荐指数
1
解决办法
1432
查看次数

标签 统计

r ×2

count ×1

dataframe ×1

filter ×1

gganimate ×1