r - 在 RStudio 中构建包时如何解决 Rd 警告 "missing file link"?

标签 r build package

在构建一个简单的测试包来隔离这个问题后,我在运行 Rcmd.exe INSTALL --nomultiarch --with-keep.source simpleTest 时收到以下警告:

* installing to library 'C:/Users/user/Documents/R-dev'
* installing *source* package 'simpleTest' ...
** R
** preparing package for lazy loading
** help
*** installing help indices
  converting help for package 'simpleTest'
    finding HTML links ...    hello                                   html  
Rd warning: C:/user/RPackages/simpleTest/man/hello.Rd:11: missing file link 'transmute'
 done
** building package indices
** testing if installed package can be loaded
* DONE (simpleTest)

当您链接到指向不同名称的 Rd 文件的函数时,会出现此问题。例如,在我的 simpleTest 包中,文档链接到 dplyr::mutate()dplyr::transmute(),两者都记录在 mutate 中。 RD 文件。前一个链接不会导致 Rd 警告,而后者会。但是,当您查看当前软件包的帮助页面时,这两个链接都有效。

simpleTest 包的 .R 文件包含在下面。我运行 devtools::document() 然后在骨架包目录中构建包。


你好.R

#' print hello
#'
#' This does something less complicated than \code{\link[dplyr:mutate]{dplyr::mutate()}} 
#' and \code{\link[dplyr:transmute]{dplyr::transmute()}}.

#' @export
hello <- function() {
  print("Hello, world!")
}

最佳答案

这是因为链接是根据文件名而不是别名创建的。如果你只使用 \link{foo}foo 是一个 topic(因此你可以毫无问题地使用别名)。但是,您使用任何形式的那一刻:

\link[pkg]{foo}
\link[pkg:foo]{bar}

foo 需要是一个 file,因此您只能使用名称而不能使用别名。如果您检查 ?dplyr::mutate,您会看到 mutate 是名称(左上角),而 transmute 是别名。因此,当您尝试使用别名时,该链接(可能)会起作用,但您会看到您看到的警告。

为避免这种情况,您需要:

\link[dplyr:mutate]{dplyr::transmute()}

引用:https://cran.r-project.org/doc/manuals/R-exts.html#Cross_002dreferences

关于r - 在 RStudio 中构建包时如何解决 Rd 警告 "missing file link"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48430093/

相关文章:

java - maven从错误的存储库下载

java - Java错误-错误的源文件:文件不包含类x。请删除或确保它出现

python - 检查要求是否是最新的

r 读取 NetCDF 并导出为 shapefile

r - 在 R 中转换/转换丰度 (OTU) 表/data.frame(到 fasta 文件)

ios - 切换到 iMac 后,React-Native 在设备上的构建变得极其缓慢

swift - 无法为 'Darwin' 加载底层模块

r - 如何从数据框中删除少于 5 个观察值的个体

image - 在 TIFF 中绘制热图时出现垂直白线

java - 用于 Java 的“类 RVM”工具