I've been trying to generate interactive linked visualizations with by use of the plotly and crosstalk libraries. As shown in the example below, it seems to be possible to pass ggplot2 a 'shared Dataframe'-Object in order to generate linked views with ggplotly(). When i try to run this example i get the following error-message:
Error: ggplot2 doesn't know how to deal with data of class SharedData/R6
I'm using the current versions of ggplot2 (v. 2.2.1) and plotly (4.5.6). What can cause this error?
Thx for help!
The example which i'm trying to replicate can be found here:
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