我已经按照here中的详细说明安装了R 3.5.1,但是某些软件包(即rJava
和XML
)存在一些问题,因此我决定卸载R 3.5 .1,然后从Ubuntu 18.04存储库降级到R 3.4.4。
我成功地做到了,但是现在,当我尝试使用以下方法在R中重新安装任何CRAN软件包时:
install.packages("ggplot2")
library(ggplot2)
我收到以下错误:
Error in dyn.load(file, DLLpath = DLLpath, ...) :
unable to load shared object '/usr/local/lib/R/site-library/Rcpp/libs/Rcpp.so':
/usr/local/lib/R/site-library/Rcpp/libs/Rcpp.so: undefined symbol: DATAPTR
ERROR: lazy loading failed for package ‘ggplot2’
* removing ‘/usr/local/lib/R/site-library/ggplot2’
* restoring previous ‘/usr/local/lib/R/site-library/ggplot2’
The downloaded source packages are in
‘/tmp/RtmpFKBMdd/downloaded_packages’
Warning message:
In install.packages("ggplot2") :
installation of package ‘ggplot2’ had non-zero exit status
>
>
>
>
> library(ggplot2)
Error: package or namespace load failed for ‘ggplot2’ in dyn.load(file, DLLpath = DLLpath, ...):
unable to load shared object '/usr/local/lib/R/site-library/Rcpp/libs/Rcpp.so':
/usr/local/lib/R/site-library/Rcpp/libs/Rcpp.so: undefined symbol: DATAPTR
In addition: Warning message:
package ‘ggplot2’ was built under R version 3.5.1
任何线索如何解决这个问题?谢谢
答案 0 :(得分:0)
确定this script(如果有兴趣的话)删除所有用户安装的软件包就像一个超级按钮。它取自here。
# Shamlessly stolen from:
# https://www.r-bloggers.com/how-to-remove-all-user-installed-packages-in-r/
# create a list of all installed packages
ip <- as.data.frame(installed.packages())
head(ip)
# if you use MRO, make sure that no packages in this library will be removed
ip <- subset(ip, !grepl("MRO", ip$LibPath))
# we don't want to remove base or recommended packages either\
ip <- ip[!(ip[,"Priority"] %in% c("base", "recommended")),]
# determine the library where the packages are installed
path.lib <- unique(ip$LibPath)
# create a vector with all the names of the packages you want to remove
pkgs.to.remove <- ip[,1]
head(pkgs.to.remove)
# remove the packages
sapply(pkgs.to.remove, remove.packages, lib = path.lib)