Repository navigation
Open
Description
Hi there,
We've been preparing a new major release for ggplot2 and found an issue during a reverse dependency check.
I couldn't dig into the root cause of the issue myself due to bumping into #9, but I'll share what the oracle told me below.
You can test your code with the development version of ggplot2 by installing it as follows:
# install.packages("pak")
pak::pak("tidyverse/ggplot2")We aim to release the new ggplot2 version in about 2 weeks, and hope you can submit a fix to CRAN around that time or let us know when ggplot2 should change. Hopefully this will inform you in a timely manner.
Best wishes,
Teun
## Newly broken
* checking examples ... ERROR
```
Running examples in ‘plotdap-Ex.R’ failed
The error most likely occurred in:
> ### Name: add_ggplot
> ### Title: Add ggplot2 elements to a plotdap object
> ### Aliases: add_ggplot
>
> ### ** Examples
>
>
...
+ crs = "+proj=laea +y_0=0 +lon_0=155 +lat_0=-90 +ellps=WGS84 +no_defs")
Loading required package: maps
> p <- add_ggplot(
+ p,
+ ggplot2::theme_bw()
+ )
Error in .Primitive("@")(NULL, properties) :
no applicable method for `@` applied to an object of class "NULL"
Calls: add_ggplot ... -> validate -> validate_properties -> @ -> do.call
Execution halted
```
* checking re-building of vignette outputs ... ERROR
```
Error(s) in re-building vignettes:
--- re-building ‘using_plotdap.Rmd’ using rmarkdown
Quitting from using_plotdap.Rmd:57-61 [world]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Error:
! no applicable method for `@` applied to an object of class "NULL"
---
Backtrace:
...
Error: processing vignette 'using_plotdap.Rmd' failed with diagnostics:
no applicable method for `@` applied to an object of class "NULL"
--- failed re-building ‘using_plotdap.Rmd’
SUMMARY: processing the following file failed:
‘using_plotdap.Rmd’
Error: Vignette re-building failed.
Execution halted
```
Metadata
Metadata
Assignees
Labels
No labels
Activity
rmendels commentedon Jun 26, 2025
@teunbrand Thanks for the heads-up. I will work on isolating where the problem occurs, but may need help in figuring out the fix. Also I have never quite figured out submissions to CRAN in cases like this, because if I resubmit before you do and I depend on the new version my submission will fail, and I have no way of testing my fix against the new version on anything other than mu local computer - always try to test with WInbuilder etc. But let me isolate the problem and see if I can fix it and then we can work out submissions.
teunbrand commentedon Jun 26, 2025
Thanks for the reponse! It depends a bit on the fix really. If the fix is both forward and backward compatible, you can put a new release on CRAN before or shortly after the ggplot2 release. If it only works with the new version, it might be best to wait until ggplot2 releases.
I'm happy to advise if I understand the issue, but it is currently obscured to me because I couldn't run tests or checks.
rmendels commentedon Jun 26, 2025
@teunbrand I am already close to figuring out the problem I think, and may need help. `plotdap' has the function which the following in it
plot$ggplot for want of a better word contains a ggplot structure, and dots[[i]] contains what is being added to the plot, The test that is failing is:
When I look at what is contained in dots[] for the old version and the new version the structure is different, so that is probably what is breaking it. Let me see if I can figure out the change (I may put in a version dependent change), or if you have a suggest of a better way to do this, let me know. Also, 'plotdap' was originally written by Carson Sievert, who now works for who?
teunbrand commentedon Jun 26, 2025
Yeah we updated all S3 classes to S7 classes, so some structures have for sure changed.
I think a problem might also be that in the following code, you'd expect the
p$ggplotto be a plot instead ofNULL.Created on 2025-06-26 with reprex v2.1.1
rmendels commentedon Jun 26, 2025
@teunbrand I didn't send you the full code, I am in the debugger now and 'plot$ggplot' is a ggplot2 structure, The problem is more fundamental than that, because the function 'add_ggplot()' gets called for all plots to adjust. So if I give just the simplest plotdap call:
in the old version I get:
while in the new version I get:
so in the old version plot$ggplot does contain the ggplot structure while in the new version plot$ggplot returns NULL. It is early here and I am also old and slow so right off I am not seeing why that should fail, but what I need to do is point to the ggplot2 structure and add the new info. So basically if I can be told how to correctly refer to the ggplot2 object that would get me started, though is quite possible other parts will still be broken. But right now that is the error being seen
teunbrand commentedon Jun 26, 2025
I think I've an idea what might go wrong. In the line below, you're appending the ggplot class to the list that contains the plot.
plotdap/R/plotdap.R
Line 73 in 4640606
This makes R think this might be an S7 object (whereas it is S3) and it goes downhill from there. If you'd replace that line with the following, it might work a lot better:
rmendels commentedon Jun 26, 2025
@teunbrand ok i think this is perhaps beyond my pay grade. Take the simplest command:
The key lines here are the following (in plotdap.R):
so if I stop after 'p2' is defined and do:
so that list is well-defined, but if I do
looking at this even more closely, if I pause and create the structure myself:
I get null, but if instead I do:
that works. If I compare class(p) in the two versions, in the new version I get:
[1] "ggplot2::ggplot" "ggplot" "ggplot2::gg" "S7_object" "gg"
while the old version just returns:
[1] "gg" "ggplot"
somehow adding that class corrupts the structure, and to be honest at this point it is beyond what I know how to fix. All we are trying to do is create an object that has the correct classes so that ggplot2 will recognize it as aa ggplot2 object.
rmendels commentedon Jun 26, 2025
@teunbrand I believe our message crossed. The question is if I only pass
will that have enough information so that ggplot2 will see that as structure as a ggplot2 structure in its internal checks. What if I used all the classes except S7?
teunbrand commentedon Jun 26, 2025
Does the
structure(p2, class = "ggplotdap")strategy not work in other parts of the package?teunbrand commentedon Jun 26, 2025
Well it will consider the
p2$ggplotpart a valid ggplot2 object. I'm not sure if theggplotdapclass needs to be a subclass if it behaves as a container class.rmendels commentedon Jun 26, 2025
@teunbrand thanks. Since I have the problem isolated, I need to go back to my real work, will test all this out later today. Thank you for your help. Will let you know.
rmendels commentedon Jun 26, 2025
@teunbrand two things. Mostly I am getting success now, except it appears to break my use of gganimate, I have two computers, both Mac with Mac silicon, the only difference between my two R's is the new ggplot2, my animations work with the old version, not with the new. Is there a new version of gganimate being worked on? I am not certain I would know how to fix this.
Also while I have your attention and as long as I am working on this, I am getting warnings about aes_() and aes_string() being deprecated, and I might as well fix that, though again I am not certain I know how to. My usages are:
Any help would be greatly appreciated
teunbrand commentedon Jun 26, 2025
Yeah there is a recent gganimate out that should be compatible with the upcoming ggplot2.
The aes_string can be translated from the following:
to this:
I think
aes_()can be replaced withaes()with the same arguments. The only difference should be if you use formulas likeaes_(x = ~foo, y = ~bar)this should then becomeaes(x = foo, y = bar).rmendels commentedon Jun 26, 2025
@teunbrand thanks. I am taking a break from this, but I should expect (hope) by Monday to have a working version that passes all my tests, as well as tests from another package that uses plotdap.
Thanks again for all of your help
rmendels commentedon Jun 26, 2025
@teunbrand I have gganimate working, and I think I have everything working. I need to do some more extensive testing and see if the changes work across versions, and test another package that uses plotdap, but I believe I basically have it as well as the changes to aes_()
Thanks,
-Roy
teunbrand commentedon Jun 27, 2025
Great, thanks for this!
rmendels commentedon Jun 29, 2025
@teunbrand - plotdap version 1.1.0 was accepted by CRAN this morning. It should work with both versions of ggplot2, at least it does on my machines. You can either wait for it to actually hit CRAN, or if you want to test it, it is available from r-universe as well as from my GitHub page - https://github.com/rmendels/plotdap/releases/tag/v1.1.0 Let me know if you find any problems.
teunbrand commentedon Jun 29, 2025
This is great, thank you so much!