【问题标题】:R: cannot install packages after downgrading from 3.5 to 3.4. Error in dyn.load(file, DLLpath = DLLpath, ...)R:从 3.5 降级到 3.4 后无法安装软件包。 dyn.load 中的错误(文件,DLLpath = DLLpath,...)
【发布时间】:2018-12-19 00:34:13
【问题描述】:

我已经按照here 中的详细说明安装了 R 3.5.1,但是我对某些软件包(即 rJavaXML)有一些问题,所以我决定卸载 R 3.5.1 并降级到 R来自 Ubuntu 18.04 存储库的 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 

任何线索如何解决这个问题?谢谢

【问题讨论】:

    标签: r ggplot2 package installation


    【解决方案1】:

    OK 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)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-10-22
      相关资源
      最近更新 更多