mike
mike

Reputation: 23811

Plotly interactivity with ggplot

Trying to get the first example from plotly with ggplot2 to work, I get the following error:

rm(list=ls())
library(plotly)

dsamp <- diamonds[sample(nrow(diamonds), 1000), ]
qplot(carat, price, data=dsamp, colour=clarity)

ggplotly()

ggplotly() Error in ggplot_build2(p) : could not find function "calculate_stats"

The chart renders, but there is no interactivity. I'm using plotly version 2.0.3 and ggplot version 2.0.0 (in RStudio v 0.99.486). Is there a specific installation step I'm missing? Thanks

Upvotes: 2

Views: 2720

Answers (2)

Antex
Antex

Reputation: 1444

This fixed the issue:

install.packages("plotly", type = "source")

Upvotes: 3

mike
mike

Reputation: 23811

Looks like you need the devtools installation of plotly:

remove.packages('plotly') # if you've installed it before
devtools::install_github("ropensci/plotly")
library('plotly')

dsamp <- diamonds[sample(nrow(diamonds), 1000), ]
qplot(carat, price, data=dsamp, colour=clarity)

ggplotly()

Upvotes: 1

Related Questions