【发布时间】:2020-01-13 00:50:58
【问题描述】:
我发现,在使用动画绘图时,您需要对每个因素进行相同数量的观察。含义 -> 一个缺失的观察结果会导致整个轨迹在动画图表的整个持续时间内被丢弃。当您使用时间序列数据并且您的一些跟踪开始较晚或结束较早时,这尤其是一个问题。除了为缺失值输入空值之外,还有其他解决方法吗?谢谢!
来自rstudio community的交叉发帖
例子:
library(gapminder)
library(plotly)
library(dplyr)
#working example with no missings
gapminder %>%
group_by(year, continent) %>%
summarise(pop = mean(pop), gdpPercap = mean(gdpPercap), lifeExp = mean(lifeExp)) %>%
plot_ly( x = ~gdpPercap,
y = ~lifeExp,
size = ~pop,
color = ~continent,
frame = ~year,
text = ~continent,
hoverinfo = "text",
type = 'scatter',
mode = 'markers')
#filtering one row results in missing Africa trace for entirety of the plot
gapminder %>%
group_by(year, continent) %>%
summarise(pop = mean(pop), gdpPercap = mean(gdpPercap), lifeExp = mean(lifeExp)) %>%
filter(gdpPercap > 1253) %>%
plot_ly( x = ~gdpPercap,
y = ~lifeExp,
size = ~pop,
color = ~continent,
frame = ~year,
text = ~continent,
hoverinfo = "text",
type = 'scatter',
mode = 'markers')
【问题讨论】:
-
仅供参考,几个月前我就这个话题filed an issue。