jimjam-slam / ggflags

A flag geom for ggplot2. Tweaks the original by using round flags (great for plotting as points).
91 stars 14 forks source link

Compatibility with R 4.2 #22

Closed jimjam-slam closed 1 year ago

jimjam-slam commented 1 year ago

Reported by a user:

set.seed(1234)
d <- data.frame(
  x = rnorm(50),
  y = rnorm(50),
  country = sample(c("ar","fr", "nz", "gb", "es", "ca", "lv", "qa"), 50, TRUE),
  stringsAsFactors = FALSE)

ggplot(d, aes(x = x, y = y, country = country, size = x)) +
  geom_flag() +
  scale_country() +
  scale_size(range = c(0, 15))

Error in class(grobs) <- "gList" : attempt to set an attribute on NULL

jimjam-slam commented 1 year ago

I'v reproduced this on R 4.1! It could be a ggplot2 update issue...

GB-IHE commented 1 year ago

I just updated to R 4.2.1. and I get the same problem again: Error in class(grobs) <- "gList" : attempt to set an attribute on NULL

Any idea why?

jimjam-slam commented 1 year ago

We're not entirely sure whether it's an R 4.2 issue or an issue with a ggplot2 change to be honest! Do you know if you also changed any packages when you upgraded, @GB-IHE? I've gotta get onto setting up some dev containers for testing!

GB-IHE commented 1 year ago

I did not change any packages, they were already up to date. I tried to go in to the source code for this package here on github for the package in order to try to find the error. However I was unsuccessful due to the number of dependencies in the code that I could not keep track of.

GB-IHE commented 1 year ago

Is there any fix comming? I would really like to use this package again.

jimjam-slam commented 1 year ago

I'm also for the wait, GB-IHE. I'd like to try and get a fix out over the holidays!

jimjam-slam commented 1 year ago

If I can carve the time out in the next week or two, I might actually fix this with a 1.0 release, which I hope in will be a major refactor using @coolbutuseless's {ggsvg}.

jimjam-slam commented 1 year ago

(I'm trying to reproduce this again on R 4.2 and ggplot2 3.4.0 and failing! Maybe this is platform-specific?)

GB-IHE commented 1 year ago

Does it work for you? I can check tomorrow if that is the case...

jimjam-slam commented 1 year ago

It does currently! I'm wondering if this is maybe a platform-specific issue: I think last time I tried this it was on a Docker image (and so would've been Linux). This is a good reason for me to add ggflags to my R-Universe and get continuous integration going!

GB-IHE commented 1 year ago

I will test it today and try and report back then

GB-IHE commented 1 year ago

You are right - it seems it works now, at least my example. Strange - maybe they updated ggplot2?

jimjam-slam commented 1 year ago

I can't say, to be honest! The only thing I can think of was either (a) a dependency somewhere in the chain that broke it and then was updated again; or (b) an issue in R 4.1 that was fixed in R 4.2.

I might try to set up continuous integration to catch fleeting issues like this!

gasparsuliansky commented 1 year ago

Hi! I currently can not work with {ggflags} on R 4.1.3.

> install.packages("ggflags")
Warning in install.packages :
  package ‘ggflags’ is not available for this version of R

Is there a way I can use it in my current environment?

PS: Big fan of the package!

jimjam-slam commented 1 year ago

Hi @GasparSuliansky! ggflags actually isn't available on CRAN—you'll need to install either remotes or devtools and then run remotes::install_github("jimjam-slam/ggflags").

With my next update I'll be sure to update the docs with installation instructions! I'll also look into getting ggflags onto my R-Universe :)

gasparsuliansky commented 1 year ago

Thanks!