安装从 CRAN 中删除的包

Installing a Package Removed from CRAN

我正在使用 R 编程语言。我正在尝试安装“使用 R 进行数据挖掘”(DMwR) 包。但是,当我访问CRAN website for this package时,它似乎消失了:

Package ‘DMwR’ was removed from the CRAN repository.
Formerly available versions can be obtained from the archive.
Archived on 2021-03-16 as check problems were not corrected despite reminders.
A summary of the most recent check results can be obtained from the check results archive.

我参观了Github page for this package

然后,我尝试直接从 Github 安装这个包:

> library(devtools)

Loading required package: usethis
Warning message:
package ‘usethis’ was built under R version 4.0.5 

> install_github("Luis Torgo/DMwR")

Error: Failed to install 'unknown package' from GitHub:
  JSON: EXPECTED value GOT <

但这也行不通。有人可以告诉我如何安装这个包吗?

您可以从 CRAN github 镜像安装它(尽管它已从 CRAN 中删除),例如

library(devtools)
install_github("cran/DMwR")

除了从 CRAN 镜像仓库安装外,另一个选择是

remotes::install_version("DMwR", version="0.4.1")
  • 对于此方法,您必须在存档目录中查找最新版本(如果您想编写代码,可能是可抓取的)
  • remotes::install_github("cran/<package>") 一样,您将从源代码安装,这意味着 如果 软件包或其任何依赖项已编译组件(在这种情况下它没有看起来不是这样),你需要在你的系统上安装开发工具(编译器等)

快速提醒:

  • 如果包最近被归档,并且归档的原因是因为 CRAN 维护者很挑剔(这是他们的特权),这将很有效;
  • 然而,自上次更新以来,包可能与当前 R 生态系统的其余部分(R 版本、依赖项)不兼容 - 在这种情况下,您可能会发现自己 dependency hell 试图安装它(或者,更糟糕的是,您的结果可能不可靠)。

R 4.1.0

上有相同的消息
install.packages("DMwR")
Warning message:
package ‘DMwR’ is not available for this version of R

一个选项也是创建一个checkpoint. According to the CRAN package website,存档于'2021-03-16'。所以,我们可以在该日期前一天使用检查点

library(checkpoint)
checkpoint("2021-03-15")
install.packages("DMwR")
library(DMwR)
#Loading required package: lattice
#Loading required package: grid
#Registered S3 method overwritten by 'quantmod':
#  method            from
#  as.zoo.data.frame zoo 

检查点也可以删除

delete_all_checkpoints()

那个包是支持2010年出版的一本书的。作者在2017年出版了第二版,当前版本的支持包是https://cran.r-project.org/web/packages/DMwR2/index.html

它确实有当前 CRAN 托管的源代码和二进制包,不需要编译,所以它应该可以安装:

install.packages("DMwR2", dependencies=TRUE)

您可以按照 Github 网站上的说明获取最新版本:

library(devtools)  # You need to install this package!
install_github("ltorgo/DMwR2",ref="develop")

那些更可能 运行 使用最新版本的 R。