1

I found a small bug in a R package. I communicated with the package author to update the code. While waiting for the author action to fix the bug, I am trying to fix the bug on my local version of the package.

I changed the R code, and also updated the MD5 of the associated file. The package is re-zipped, and I use this command to install it:

install.packages("path/to/the/file/modified_package.zip", repos = NULL)

it seems the installation is going well:

Installing package(s) into ‘C:/Users/Me/Documents/R/win-library/2.15’
(as ‘lib’ is unspecified)
package ‘x’ successfully unpacked and MD5 sums checked

However, when I try to load the package, there is an error:

> library(x)
Error in library(x) : ‘x’ is not a valid installed package

Any thoughts?

4

1 回答 1

3

您不能只是压缩目录;你需要重建包。

有很多关于如何构建 R 包的指南。最简单的方法(恕我直言)是使用devtools包。

library(devtools)

build("path/to/the/package")
install.packages("path/to/built/package.tar.gz", repos = NULL, type = "source")

或者

build("path/to/the/package", binary = TRUE)
install.packages("path/to/built/package.zip", repos = NULL, type = "win.binary")

如果您正在运行 Windows,您还需要 Rtools。将其与installr软件包一起安装。

library(installr)
install.Rtools()
于 2013-06-11T19:41:06.297 回答