在 R 4.0.0 之前安装了包“xxx”:请重新安装它(已经完成全新安装并检查了 lib 路径)

Package 'xxx’ was installed before R 4.0.0: please re-install it (already done fresh install and checked lib paths)

我在从二进制文件安装 R 4.0.2 包时遇到了一些问题。这是我的尝试:

> install.packages("C:/Users/MNestor/Downloads/libSBML_5.18.0.zip", repos = NULL, type = "win.binary")
Installing package into ‘C:/Users/MNestor/Documents/R/win-library/4.0’ (as ‘lib’ is unspecified)
package ‘libSBML’ successfully unpacked and MD5 sums checked
Warning messages:
1: multiple methods tables found for ‘type’ 
2: multiple methods tables found for ‘type<-’ 

接下来我加载库:

> library('libSBML')
Error: package or namespace load failed for ‘libSBML’:
 package ‘libSBML’ was installed before R 4.0.0: please re-install it

这个错误让我感到困惑,因为我在 R 4.0.2 中工作并且显然刚刚完成了全新安装。

我试过了

  1. 删除库文件夹并重新安装
  2. 运行 remove.packages('libSBML') 并重新安装

这里是我的图书馆目录供参考:

> .libPaths()
[1] "C:/Users/MNestor/Documents/R/win-library/4.0"
[2] "C:/Program Files/R/R-4.0.2/library"   

libSMBL 文件夹位于第一个库路径,而不是第二个(如预期的那样)。

这是会话信息:

> sessionInfo()
R version 4.0.2 (2020-06-22)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 17134)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252   
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C                          
[5] LC_TIME=English_United States.1252    

attached base packages:
[1] parallel  stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] rsbml_2.46.0        BiocGenerics_0.34.0

loaded via a namespace (and not attached):
[1] BiocManager_1.30.10 compiler_4.0.2      tools_4.0.2         remotes_2.2.0      
[5] stats4_4.0.2        SBMLR_1.84.0        graph_1.66.0  

错误消息可能有点令人困惑,但它是说该包已经为早期版本的 R 编译。(这就是选项“win.binary”的意思)。

R 4.0 和更早的二进制文件不兼容,因为更新了编译器和构建工具。

您需要从源代码安装包,这可能意味着安装 R 工具 (https://cran.r-project.org/bin/windows/Rtools/),或者您需要为 R 4.0 或更高版本使用 pre-built 版本.