✊🏿 Black Lives Matter. Please consider donating to Black Girls Code today.
🧬 Learn how to build RNA-Seq data apps with Python & Dash. Register for the May 20 Webinar!

Cannot find function animation_opts

Hi all,

I am trying the code on the instruction page for animation view, however it give me this error: Error in function_list[i] :
could not find function “animation_opts”

Does anyone know how to access function? is there any other package i should download?

Thanks!!

Here is the code I copied from the webpage.

library(plotly)
library(ggplot2)

data(gapminder, package = “gapminder”)
gg <- ggplot(gapminder, aes(gdpPercap, lifeExp)) +
geom_point(aes(size = pop, color = continent)) +
scale_x_log10()
ggplotly§

base <- gapminder %>%
plot_ly(x = ~gdpPercap, y = ~lifeExp, size = ~pop, text = ~country, hoverinfo = “text”) %>%
layout(xaxis = list(type = “log”))

base %>%
add_markers(color = ~continent, frame = ~year, ids = ~country) %>%
animation_opts(1000, easing = “elastic”) %>%
animation_button(x = 1, xanchor = “right”, y = 0, yanchor = “bottom”) %>%
animation_slider(currentvalue = list(prefix = "YEAR ", font = list(color = “red”)))

Hey @hiroshial,

try installing the development version devtools::install_github(“ropensci/plotly”)

Thanks! i tried! it works now!.. and i forget to upddate my R too (Now it is 3.3.2)… but i still have problem running the instruction code in the guid book:

base %>%
add_markers(color = ~continent, frame = ~year, ids = ~country) %>%
animation_opts(1000, easing = “elastic”) %>%
animation_button(x = 1, xanchor = “right”, y = 0, yanchor = “bottom”) %>%
animation_slider(currentvalue = list(prefix = "YEAR ", font = list(color = “red”)))

It is " animation_button(x = 1, xanchor = “right”, y = 0, yanchor = “bottom”) %>%" cause the problem:
Error in p$x$layout$updatemenus[[which(isAniButton)]] :
attempt to select less than one element in get1index

do you know how to fix this ?

great thanks!

I’m having the same issue. When I try to install the development version with the code: devtools::install_github(“ropensci/plotly”) I get the error:

Downloading GitHub repo ropensci/plotly@master
from URL https://api.github.com/repos/ropensci/plotly/zipball/master
Error in curl::curl_fetch_memory(url, handle = handle) : 
Couldn't resolve host name

I resolved by first, you have to connect with the host:
First, run this code:
Sys.setenv(“plotly_username”=“YOUR USER NAME”) ## modife your user name to your username
Sys.setenv(“plotly_api_key”=“YOUR API KEY”) ## find your api key in your profile

Second, run the development version code:
devtools::install_github(“ropensci/plotly”)

Make sure your R is updated and also your Rstudio is updated. Plotly has some issues in R 3.2.x

Hope it helps

Hiroshial