Skip to content
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

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

Closed
tungttnguyen opened this issue Apr 25, 2023 · 8 comments

Comments

@tungttnguyen
Copy link

I ran into a problem with ggplotly(). The following example worked with the CRAN version 3.4.2 but not with the dev version. Thanks!

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()
plt1

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

Created on 2023-04-24 with reprex v2.0.2

@smouksassi
Copy link

please note that plotly has a different repo:
https://github.com/plotly/plotly.R/issues

@tungttnguyen
Copy link
Author

please note that plotly has a different repo: https://github.com/plotly/plotly.R/issues

The recent changes in ggplot2 broke working codes. That's why I thought I should report it here

@teunbrand
Copy link
Collaborator

This looks to me like a change in the internals have broken something in plotly.

If we look up the source of the ggfun() function that throws the error here:

https://github.com/plotly/plotly.R/blob/10e010088751efd5670d4daf2970b2eb5d91ea1a/R/ggplotly.R#L1393-L1395

We can see plotly uses the getFromNamespace() trick mentioned by Thomas at this post. Admittedly, I have also used that trick, but the trick is very fragile because ggplot2 might change internals as they see fit.

In any case, it might make sense to loop in @cpsievert about this change sooner rather than later. I think the break stems from #5144, and it might make it easier to avoid getFromNameSpace() because the scales functions are now encapsulated in the ScalesList class that can be accessed at build time.

@tungttnguyen
Copy link
Author

This looks to me like a change in the internals have broken something in plotly.

If we look up the source of the ggfun() function that throws the error here:

https://github.com/plotly/plotly.R/blob/10e010088751efd5670d4daf2970b2eb5d91ea1a/R/ggplotly.R#L1393-L1395

We can see plotly uses the getFromNamespace() trick mentioned by Thomas at this post. Admittedly, I have also used that trick, but the trick is very fragile because ggplot2 might change internals as they see fit.

In any case, it might make sense to loop in @cpsievert about this change sooner rather than later. I think the break stems from #5144, and it might make it easier to avoid getFromNameSpace() because the scales functions are now encapsulated in the ScalesList class that can be accessed at build time.

Thanks @teunbrand for checking! I opened an issue on plotly.R to report it

@teunbrand
Copy link
Collaborator

Thanks for propagating the issue! I'll close this here then.

@teunbrand teunbrand closed this as not planned Won't fix, can't repro, duplicate, stale May 2, 2023
@fsalemi
Copy link

fsalemi commented Feb 26, 2024

@tungttnguyen Hi there,
Were you able to resolve this issue? I am still getting this error:
Error in match.fun(FUN) : 'ggfun("scales_transform_df")' is not a function, character or symbol

Thanks

@cpsievert
Copy link
Contributor

@fsalemi have you tried updating plotly?

@fsalemi
Copy link

fsalemi commented Feb 26, 2024

@cpsievert Thank you for your response. I did upgrade plotly on my new computer last year. However, I was using my old laptop for a quick question yesterday, and I forgot the plotly version was still the old one.
Thanks again.

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

No branches or pull requests

5 participants