5

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
tlo
  • 86
  • 5
  • You'd need to install the dev version `devtools::install_github("ropensci/plotly")`. Restart R if you face installation issues. – Karthik Arumugham Feb 22 '17 at 14:37
  • If you face an issue like I did after `ggplotly(gg)` - `Error: No graphics device is currently open and no cairo or bitmap device is available.`, then run `quartz()` before `ggplotly(gg)` – Karthik Arumugham Feb 22 '17 at 14:41
  • The working packages versions I used : plotly 4.5.6.9000, ggplot2 2.2.1.9000 – Karthik Arumugham Feb 22 '17 at 14:44
  • Thanks a lot! With the plotly development version, ggplot does now accept the shareddata-object. However, when i call ggplotly in the next step i get a further Error message: **Error in ggfun("create_layout")(plot$facet, plot$coordinates): unused argument (plot$coordinates)** – tlo Feb 22 '17 at 15:34
  • 1
    No idea. I suggest you raise an issue @ https://github.com/ropensci/plotly/issues with your environment details. – Karthik Arumugham Feb 22 '17 at 15:41
  • it is working now - after reinstalling ggplot2 2.2.1.9000. Thanks again for your help! – tlo Feb 23 '17 at 08:36

0 Answers0