Problems with new R version [duplicate] - r

I just updated to R 4.1.0 and re-installed my packages and Rstudio (on Ubuntu 20.04). Now R runs out of memory and crashes when I try to make any ggplot. The error message is long and I can't fully read it because the R session immediately aborts, but it mentions "missing nul terminator", "process memory read out of range" and a bunch of lines of [XXXX:XXXX:YYYYYYYY,ZZZZZZ,AAAAAA ERROR: elf_dynamic_array_reader.h:61] tag not found and finally [XXXX:XXXX:YYYYYYYY,ZZZZZZ,AAAAAA] ERROR directory_reader_posix.cc:42] opendir: No such file or directory (2) (where X, Y, Z, and A are numbers).
I originally got this error with my data but it seems to happen with any ggplot:
library(ggplot2)
ggplot(mtcars, aes(x = cyl, y = mpg)) + geom_boxplot()
I think it's to do with actually displaying the plot because it doesn't crash when I save the plot into a variable and then ggsave() it, and the resulting file is fine. It's also OK when I do ggplot(...) within a function with ggsave() in the next line.
The same plot in base R works fine.
boxplot(mpg~cyl, data = mtcars)
==> displays boxplot in the Plots pane
Reinstalling ggplot2 with install.packages() didn't fix the problem, and I tried to sudo apt install ./rstudio-1.4.1106-amd64.deb again but it just says Rstudio is already the newest version.

This tweet from Kevin Ushey says:
PSA: If you're an RStudio user planning to upgrade to R 4.1.0, you may want to install the preview release of RStudio (https://rstudio.com/products/rstudio/download/preview/) -- otherwise, you may see RStudio crash when you try to use ggplot2.
The version number is "1.4.1714-2 Preview", so well ahead of the 1.4.1106 version you're installing via apt. Release notes on that page include
Support for the upcoming R 4.1.0 release, including the new |> pipe, (x) function shorthand, and new graphics engine.
Another alternative would be to downgrade R to an older version; for Windows the 4.0.5 binary appears to be available here. Unfortunately, the MacOS download page only appears to offer 3.6.3 in previous versions (not any 4.0.x releases) — which feels like a long way to downgrade.

I just had this same issue and checked RStudio for an update. They now have, at the time of writing this, version 1.4.1717 for Debian/Ubuntu (I am running Ubuntu 20). Updating has fixed my ggplot issue with the same warnings.

Related

Rstudio and R both freeze when plotting with plot() and ggplot()

I have a problem since that has to do with plotting in R and Rstudio. I am using a MacBook Pro 14'' with macOS Monterey Version 12.1. The RStudio version is 2022.12.0+353 (2022.12.0+353), and the R version is 4.2.2.
I was previously using R 4.2.0 and a previous version of RStudio and still the plots did not show up.
What happens is that as soon as I try to plot anything, the panel freezes and the only way to go forward is to press the red "stop" button of the console. Usually, the only way to go is to restart R because pressing the stop button is not enough. It happens with any plotting function that I am aware of, including ggplot(), hist(), and plot().
I have already tried to restart the laptop, to unload the packages and to update them.
Did anybody encounter a similar issue? It's quite puzzling to me.
Thanks,
Marco
I have already tried to restart the laptop, to unload the packages and to update them.
I solved the problem. my system did not recognise the Arial font. After installing it manually, ggplot worked again.
Thanks!
M

How to get an rgl plot output under Ubuntu 22.04?

When plotting something with the rgl package for R on an Ubuntu 22.04 LTS machine, how can I get any plot output?
When I run a plot command, I am not getting any plot window or visual output. E.g., the README of rgl suggests the following to run a demo:
library("rgl")
demo("rgl")
but it shows no plot windows when I browse through the demos (by hitting return several times). All I get is text in the R console.
What I have tried:
I noticed the following during the rgl package installation:
install.packages("rgl")
This completes without error, but I get the following message during the configure phase of the build process:
checking for X... no
configure: WARNING: X11 not found, continuing without OpenGL support.
and if I load rgl afterwards, using library(rgl), you get a notice:
library(rgl)
This build of rgl does not include OpenGL functions. Use
rglwidget() to display results, e.g. via options(rgl.printRglwidget = TRUE).
If I follow the advice given there, i.e., first run options(rgl.printRglwidget = TRUE); demo(rgl);, then it opens one tab in my browser (firefox) per demo, and all tabs show File not found errors for temporary files like /tmp/RtmpWqj4zX/viewhtml53511cd8b2f5/index.html..
I am running a graphical user interface, so I found it strange that X11 was not being found, maybe this is because my system is using Wayland: grep -i wayland /etc/gdm3/custom.conf outputs WaylandEnable=true. However, this is pure speculation.
To repeat, my question is, how can I get rgl plot output under Ubuntu 22.04? I would prefer to have an X11 window open, but the browser-based rendering would be better than nothing.
System info:
Ubuntu version (the VERSION of cat /etc/os-release): 22.04.1 LTS (Jammy Jellyfish)
R version (from R --version in shell): 4.1.2 (2021-11-01) -- "Bird Hippie"
rgl version (from packageVersion("rgl") in R): 0.110.2
Note: This is a machine under control of our IT department, I have no root access.

R crashing while displaying ggplot after update (process memory read out of range)

I just updated to R 4.1.0 and re-installed my packages and Rstudio (on Ubuntu 20.04). Now R runs out of memory and crashes when I try to make any ggplot. The error message is long and I can't fully read it because the R session immediately aborts, but it mentions "missing nul terminator", "process memory read out of range" and a bunch of lines of [XXXX:XXXX:YYYYYYYY,ZZZZZZ,AAAAAA ERROR: elf_dynamic_array_reader.h:61] tag not found and finally [XXXX:XXXX:YYYYYYYY,ZZZZZZ,AAAAAA] ERROR directory_reader_posix.cc:42] opendir: No such file or directory (2) (where X, Y, Z, and A are numbers).
I originally got this error with my data but it seems to happen with any ggplot:
library(ggplot2)
ggplot(mtcars, aes(x = cyl, y = mpg)) + geom_boxplot()
I think it's to do with actually displaying the plot because it doesn't crash when I save the plot into a variable and then ggsave() it, and the resulting file is fine. It's also OK when I do ggplot(...) within a function with ggsave() in the next line.
The same plot in base R works fine.
boxplot(mpg~cyl, data = mtcars)
==> displays boxplot in the Plots pane
Reinstalling ggplot2 with install.packages() didn't fix the problem, and I tried to sudo apt install ./rstudio-1.4.1106-amd64.deb again but it just says Rstudio is already the newest version.
This tweet from Kevin Ushey says:
PSA: If you're an RStudio user planning to upgrade to R 4.1.0, you may want to install the preview release of RStudio (https://rstudio.com/products/rstudio/download/preview/) -- otherwise, you may see RStudio crash when you try to use ggplot2.
The version number is "1.4.1714-2 Preview", so well ahead of the 1.4.1106 version you're installing via apt. Release notes on that page include
Support for the upcoming R 4.1.0 release, including the new |> pipe, (x) function shorthand, and new graphics engine.
Another alternative would be to downgrade R to an older version; for Windows the 4.0.5 binary appears to be available here. Unfortunately, the MacOS download page only appears to offer 3.6.3 in previous versions (not any 4.0.x releases) — which feels like a long way to downgrade.
I just had this same issue and checked RStudio for an update. They now have, at the time of writing this, version 1.4.1717 for Debian/Ubuntu (I am running Ubuntu 20). Updating has fixed my ggplot issue with the same warnings.

RStudio does not render Plotly plot on new machine

I bought a new laptop a few days ago (Windows 10) and installed R 4.0.0 and the last RStudio version (Desktop 1.2.5042) on it. Subsequently I ran the rtools40 installer and installed the latest versions of the popular R packages (including ggplot, plotly and so on). Everything seems to work, except for the RStduio viewer pane when trying to render a plotly plot. What happens is that, when I run a minimal example (like this https://plotly.com/r/line-charts/) the view pane is activated, but no plot is rendered. Also no error is raised and the RStudio R session starts draining a lot of CPU capacity, although no code is apparently running (e.g. I can run a plot() and it will be properly displayed in the plot pane).
Now, I've tried downgrading and running RStudio (3.x) from Anaconda - neither worked.
Also - my browser wold not render local plotly plots, bit it would render external plots (like in the example above https://plotly.com/r/line-charts/).
Any ideas?
Apparently it is an issue with R 4.0 and RStudio 1.2.5042 on Windows 10 x64:
https://github.com/rstudio/rstudio/issues/6737
I downgraded to R 3.6.1 and RStudio 1.2.5042 and the problem is gone.
RStudio is due to fix the issue with its v1.3-patch.

cannot load rgl package without manually launching Xapp

I initially tried, using RStudio, to install rgl using install.packages("rgl"), which appeared to have worked. It did give me a message that the binary is older than the source, and that it would install from the binary, but I received no other messages. However library(rgl) gets stuck and doesn't do anything.
I removed the package using remove.packages(rgl), and attempted to install from source using R CMD INSTALL rgl_0.95.1409.tar.gz. That gets stuck on "testing if installed package can be loaded." I had X11 installed, but I downloaded XQuartz 2.7.8 and tried again, with the same result.
?rgl::plot3d in RStudio does take me to the documentation for the plot3d function, so I think it installed, just not completely/successfully (rgl::plot3d as an attempt to call the plot3d function also results in endless computation).
However, I finally did manage to load rgl (and use plot3d) by manually launching the Xapp from the Terminal prior to loading the library in my current R session (just X in Terminal, xterm by itself doesn't seem to have the same effect). Can anyone explain why this might be the case, and if there is a workaround to avoid having to manually launch the Xapp? (I do not want to have an application running when I do not need it, but I will also probably sometimes forget to launch the Xapp prior to running this script.)
I'm running OS X Yosemite (10.10.5), RStudio 0.98.1103, R 3.1.3 3.2.2.
The 'rgl' package does not use XQuartz, but rather opens a separate X11 window. Not being able to launch X(11) automatically makes me think that either your system PATH does not have the X11 server in the search path or an environment variable needs to be fixed. I wasn't able to see any differences in the Sys.getenv() results after loading rgl but I see that I have these in my PATH: /usr/X11/bin:/usr/X11R6/bin1
For a while I was rather confused about this as well. The XQuartz.app appeared very similar to the the X11.app , showing up with the very similar icons, (both appearing in the Taskbar as "X".)

Resources