Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot plot geom_point in R ggplot2

I am trying to make a simple plot, similar to that (this code also gives me the error):

df = data.frame(x=c(1,2,3,4),y=c(4,5,1,5))
ggplot(df) + geom_point(aes(x,y))

Other functions like geom_jitter etc. work seamlessly.

I've tried R 4.5.1 and R 4.5.2 and I still get the following error:

Error in list2(na.rm = na.rm, ...): object 'ffi_list2' not found
Traceback:

1. layer(mapping = mapping, data = data, geom = "point", stat = stat, 
 .     position = position, show.legend = show.legend, inherit.aes = inherit.aes, 
 .     params = list2(na.rm = na.rm, ...))
2. list2(na.rm = na.rm, ...)
3. .handleSimpleError(function (cnd) 
 . {
 .     watcher$capture_plot_and_output()
 .     cnd <- sanitize_call(cnd)
 .     watcher$push(cnd)
 .     switch(on_error, continue = invokeRestart("eval_continue"), 
 .         stop = invokeRestart("eval_stop"), error = NULL)
 . }, "object 'ffi_list2' not found", base::quote(list2(na.rm = na.rm, 
 .     ...)))

This happens regardless of the environment. Pure R, JupyterLab, R Studio. How to workaround this?

like image 389
Wojciech Artichowicz Avatar asked Sep 07 '26 11:09

Wojciech Artichowicz


1 Answers

Update: The ggplot2 patch is on CRAN now, so if you update ggplot2 to >=4.0.2 with install.packages("ggplot2") and then restart R, then the problem should go away.

---

I believe this is an unfortunate result of ggplot2 accidentally (at least I don't think it was on purpose) capturing rlang::list2()'s definition at ggplot2 build time.

I have documented this issue here https://github.com/tidyverse/ggplot2/issues/6796, we will try and get out a ggplot2 release soon that fixes this.

I believe if you do the following, you can get back up and running:

  • remove.packages("rlang")

  • Restart R to be safe

  • install.packages("rlang")

  • Restart R to be safe

  • Try your code again

That should put you on rlang 1.1.7, which has ffi_list2.

like image 98
Davis Vaughan Avatar answered Sep 10 '26 01:09

Davis Vaughan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!