包车无法加载,nlme 版本错误

package car unable to load, wrong version of nlme

当我尝试加载 'car' 包时出现此错误:

library(car)

Error in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]) : 
  namespace 'nlme' 3.1-122 is already loaded, but >= 3.1.123 is required
Error: package or namespace load failed for 'car'

但是当我运行update.packages()没有什么可更新的。如果重要的话,我正在使用 MRO 3.2.3。

我遇到了同样的问题,只需从 https://cran.r-project.org/src/contrib/Archive/nlme/

安装 nlme_3.1-123.tar.gz 即可解决

您的问题的最终原因很可能是 MRO defaults to a static repository:

By default, Microsoft R Open offers its users predictability using a static CRAN snapshot date. For example, the CRAN repository for Microsoft R Open 3.2.3 is configured to point to a snapshot date of Jan 1, 2016. Consequently, with Microsoft R Open 3.2.3 you'll always get packages as they were at midnight UTC on Jan 1, 2016 by default whenever you use install.packages.

Using a fixed CRAN repository snapshot means that every user of Microsoft R Open has access to the same set of CRAN package versions. This makes sharing R code that relies on R packages easier, and reduces the chance of incompatible R packages being installed on the same system. Learn more about fixed CRAN repository snapshots.

尝试

install.packages("nlme",repos="http://cran.r-project.org")

或者可能

install.packages("nlme",repos="http://cran.r-project.org",type="binary")

(如果出现 type == "both" cannot be used ... 错误)。

推荐软件包新版本的另一个可能问题来源是,旧版本可能安装在系统级软件包目录中,而新版本安装在用户级目录;查看

的结果
sapply(.libPaths(),packageVersion,pkg="nlme") 

并考虑在您的 install.packages() 调用中添加类似 lib=.libPaths()[2] 的内容。