-
Notifications
You must be signed in to change notification settings - Fork 11
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
thematic_on breaks if another package includes ggplot (maybe?) #90
Comments
This comment has been minimized.
This comment has been minimized.
Interesting, thanks for the report. Is your package publicly available? |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Looks like the problem derives from the zoo package (a dependency of these packages): > library(zoo); thematic::thematic_on()
Error in get(S3[i, 1L], mode = "function", envir = parent.frame()) :
invalid first argument |
Turns out that library(ggplot2)
# works
ggplotBuild <- getFromNamespace("ggplot_build.ggplot", "ggplot2")
assignInNamespace("ggplot_build.ggplot", function(x) { warning("owned"); ggplotBuild(x) }, "ggplot2")
qplot(1:10)
# doesn't work
library(zoo)
assignInNamespace("ggplot_build.ggplot", function(x) { warning("owned"); ggplotBuild(x) }, "ggplot2")
#> Error in get(S3[i, 1L], mode = "function", envir = parent.frame()) :
#> invalid first argument And this happens because the S3 lookup matrix turns into a list when is.matrix(.getNamespaceInfo(asNamespace("ggplot2"), "S3methods"))
#> TRUE
library(zoo)
is.matrix(.getNamespaceInfo(asNamespace("ggplot2"), "S3methods"))
#> FALSE I may submit a bug to R core for this, but in the meantime, I think I can have thematic workaround this |
…od() inside .onLoad() to register ggplot2 methods
Tested s3methods-matrix branch. My problem has gone away. Thanks! |
… .onLoad() to register ggplot2 methods (#91) * Close #90: Get thematic working with packages that use registerS3method() inside .onLoad() to register ggplot2 methods * Improve comment and also ensure S3methods matrix when restoring previous ggplot_build * New ragg baselines * update news; approve ragg mac baseline
Hi. I still face the same problem
Here is my sessionInfo
|
You need the development version |
Hi, I'm still receiving this error as well.
I'm receiving the following error both in isolated code chunks that generate ggplot visuals and during markdown knit.
|
@michaelgaunt404 your |
If that doesn't fix your issues, you might need to update to a more recent version of R |
The problem
I have a shiny app built as a package with golem that uses many plotting libraries including ggplot2 and as soon as I tried thematic_on or thematic_shiny I got:
"Error in get(S3[i, 1L], mode = "function", envir = parent.frame()): invalid first argument".
I digged in and discovered that the same problem that happens with my package, happens with others that include ggplot2:
Created on 2021-02-16 by the reprex package (v1.0.0)
Further digging on thematic's code
On another box I set out to debug thematic. I cloned it and this is what I did.
On this function I put a browser:
Discovered that the aforementioned "get" problem with S3 comes from assign_in_namespace("ggplot_build.ggplot", ggthematic_build, "ggplot2"). So I copied the assign_in_namespace (from assignInNamespace, as it does in the code), but set a browser on that.
What I discovered is that inside the assignInNamespace code, down by the line:
S3[i,1L] returns a list that contains the name of the function, but get wants a string. So, as you can see:
This goes away if one rewrites with:
Or at least the error does. Im not keen on hacking away at this because im pretty much a newb (i've no idea how S3 or namespaces actually work), but I think this is either a freakish mismanagement of my base packages (e.g. i carry a bug in utils::assignInNamespace), or a particular use of it that got mangled somewhere.
I LOVE the thematic idea. I want to use it! Let me know if I can help out.
The text was updated successfully, but these errors were encountered: