Skip to content

Error in match.fun(FUN): 'ggfun("scales_transform_df")' is not a function, character or symbol #2259

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
tungttnguyen opened this issue Apr 25, 2023 · 0 comments · Fixed by #2262

Comments

@tungttnguyen
Copy link

tungttnguyen commented Apr 25, 2023

FYI, future changes in ggplot2 will break ggplotly(). The following example did not work with the development version of ggplot2.
See also this discussion

library(dplyr)
library(ggplot2)
packageVersion("ggplot2")
#> [1] '3.4.2.9000'

data("airquality")

airquality <- airquality %>% 
  select(Month, Day, Temp) %>% 
  mutate(Date = as.Date(paste("1973", Month, Day, sep = "-")))

plt1 <- ggplot(airquality,
               aes(x = Date,
                   y = Temp)) +
  geom_line() +
  theme_bw()
library(plotly)
packageVersion("plotly")
#> [1] '4.10.1'

ggplotly(plt1, 
         tooltip = c("x", "y", "color", "text"),
         dynamicTicks = TRUE) %>% 
  rangeslider() %>%
  layout(
    legend = list(orientation = "h", x = 0.1, y = -0.5)
  )
#> Error in match.fun(FUN): 'ggfun("scales_transform_df")' is not a function, character or symbol

https://github.com/plotly/plotly.R/blob/master/R/ggplotly.R#L317

# Transform all scales
data <- lapply(data, ggfun("scales_transform_df"), scales = scales)

https://github.com/plotly/plotly.R/blob/master/R/ggplotly.R#L1391-L1395

# We need access to internal ggplot2 functions in several places
# this helps us import functions in a way that R CMD check won't cry about
ggfun <- function(x) {
  tryCatch(getFromNamespace(x, "ggplot2"), error = function(e) NULL)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant