r - R:从 3.5 降级到 3.4 后无法安装软件包。dyn.load 中的错误(文件,DLLpath = DLLpath,...)
问题描述
我已经按照此处的详细说明安装了 R 3.5.1 ,但是我对某些软件包(即rJava
and )有一些问题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
任何线索如何解决这个问题?谢谢
解决方案
好的,如果有人感兴趣,这个删除所有用户安装包的脚本就像一个魅力。它是从这里取来的。
# 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)
推荐阅读
- animation - SwiftUI 如何使圆形动画双向工作
- python - 将 django 与 postgresql 连接起来
- javascript - 使用节点和猫鼬导出时出错
- c# - 动态分配 asp-for 变量
- python - 如何计算特定日期之间数据框索引的每周平均值?
- java - Spring JPA“一对多”加载的对象属于错误的类
- javascript - 使用 node-postgres 执行查询时,aws lambda 不返回任何内容
- javascript - axios get请求后访问json数据
- python - Python中列表从2到N的唯一排列
- python - 如何在由掩码指定的较大数组中的不同位置应用相同的一组值?