背景
最近碰到画图不显示问题,一开始常规操作dev.off()关闭画图器,没想到还是不行
解决方案
升级r到4.4.1后发现
在输出library(ggplot2)或者.libPaths()会提示 当前rstudio版本过低,导致图片不显示。
- 升级rstudio
- 降级r
检查ubuntu 22.04lt 系统,rstudio-server是2022版本,r一开始不显示图片用的是4.3.0版本(升级到4.4.1发现的)
决定降级r到3.6.3版本
命令如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
| # Install required dependencies sudo apt-get update sudo apt-get install gdebi-core
# Specify R version, download and install R export R_VERSION=4.2.3 curl -O https://cdn.rstudio.com/r/ubuntu-2004/pkgs/r-${R_VERSION}_1_amd64.deb sudo gdebi r-${R_VERSION}_1_amd64.deb /opt/R/${R_VERSION}/bin/R --version
# Create a symlink to R sudo ln -s /opt/R/${R_VERSION}/bin/R /usr/local/bin/R sudo ln -s /opt/R/${R_VERSION}/bin/Rscript /usr/local/bin/Rscript
# config rstudio-server vim /etc/rstudio/rserver.conf # rsession-which-r=/usr/local/bin/R sudo rstudio-server restart
|
重启后版本匹配,验证也出图了。