我一直在尝试使用plotly和crosstalk库生成交互式链接可视化。如下面的示例所示,似乎可以通过ggplot2传递'共享Dataframe'-Object,以便使用ggplotly()生成链接视图。当我尝试运行此示例时,我收到以下错误消息:
错误:ggplot2不知道如何处理类SharedData / R6的数据
我正在使用当前版本的ggplot2(v.2.2.1)和plotly(4.5.6)。什么可能导致此错误?
寻求帮助!
我试图复制的例子可以在这里找到:
https://cpsievert.github.io/plotly_book/linking-animated-views.html
library(gapminder)
library(crosstalk)
library(ggplot2)
library(plotly)
g <- crosstalk::SharedData$new(gapminder, ~continent)
gg <- ggplot(g, aes(gdpPercap, lifeExp, color = continent, frame = year)) +
geom_point(aes(size = pop, ids = country)) +
geom_smooth(se = FALSE, method = "lm") +
scale_x_log10()
ggplotly(gg) %>%
highlight("plotly_hover")
Error: ggplot2 doesn't know how to deal with data of class SharedData/R6