我用RStudio创建了一个新包。在“配置构建工具”中,我检查“用RO2生成文档”。
当我第一次单击"Build“窗格中的”文档“时,一切正常:
==> roxygen2::roxygenize('.', roclets=c('rd', 'collate', 'namespace'))
First time using roxygen2. Upgrading automatically...
Writing hello.Rd
Writing NAMESPACE
Documentation completed我得到了这个名称空间:
# Generated by roxygen2: do not edit by hand
export(hello)而这个文件hello.Rd
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/hello.R
\name{hello}
\alias{hello}
\title{Hello}
\usage{
hello(x)
}
\arguments{
\item{x}{string}
}
\value{
a string
}但是现在,我修改了文件hello.R,然后我遇到了两个问题。首先,这个窗口显示:

如果我点击“是”,什么都不会发生。
其次,roxygen2似乎不能覆盖hello.Rd,因为我在"Build“窗格中获得了这个文本:
==> roxygen2::roxygenize('.', roclets=c('rd', 'collate', 'namespace'))
Error: The specified file is not readable: U:\Data\Rtests\testPackage\man/hello.Rd
Execution halted
Exited with status 1.我发现更新文档的唯一方法是运行:
roxygen2::roxygenize(clean=TRUE)该命令首先清除所有内容,命名空间和Rd文件,然后生成名称空间和Rd文件。
我不知道这是否是Rtools路径的问题。我试图通过这样做来设置路径:
Sys.setenv(PATH="%PATH%;C:/Program Files/Rtools/gcc-4.6.3/bin;C:/Program Files/Rtools/gcc-4.6.3/bin64;C:/Program Files/Rtools/gcc-4.6.3/i686-w64-mingw32/bin;C:/Program Files/Rtools/bin")但这并不能解决问题。
我在用:
roxygen2 5.0.1R version 3.3.1发布于 2016-11-11 15:11:41
问题的原因。
roxygen2包依赖于digest包。错误(指定的文件不可读)由digest包的digest函数生成,此时该函数调用file.access函数:https://github.com/eddelbuettel/digest/blob/master/R/digest.R#L102。
我得到:
> file.access("U:/Data", 4)
U:/Data
-1 这意味着U:/Data没有读取权限。但这不是真的:它有读取权限。问题是我的U:驱动器是“网络驱动器”,网络驱动器的file.access函数存在一些问题,例如:https://github.com/eddelbuettel/digest/issues/13。
解决办法
如果在R.utils::fileAccess函数中使用file.access而不是file.access,问题就会得到解决。
因此,首先使用digest::digest函数的代码并对其进行如下修改。
mydigest <- function (object, algo = c("md5", "sha1", "crc32", "sha256",
"sha512", "xxhash32", "xxhash64", "murmur32"), serialize = TRUE,
file = FALSE, length = Inf, skip = "auto", ascii = FALSE,
raw = FALSE, seed = 0, errormode = c("stop", "warn", "silent"))
{
file.access <- R.utils::fileAccess
.... the code of the digest function here ...
}那就做:
library(digest)
R.utils::reassignInPackage("digest", "digest", mydigest)现在,可以通过以下操作更新文档:
roxygen2::roxygenize()https://stackoverflow.com/questions/40530968
复制相似问题