在文档对象中发现错误的 \usage 行
Bad \usage lines found in documentation object
我无法让我的包裹通过 R CMD 检查。我正在使用 devtools
版本 1.9.1 和 Roxygen2
版本 4.1.1。我遇到的问题如下:
Bad \usage lines found in documentation object 'my_fn':
Functions with \usage entries need to have the appropriate \alias
entries, and all their arguments documented.
The \usage entries must correspond to syntactically valid R code.
See chapter 'Writing R documentation files' in the 'Writing R
Extensions' manual.
正如您所见,它实际上并没有给我任何关于问题发生位置的指示。就是2个空格。
我的函数如下:
#' My function
#'
#' Extracts data from the database in order to produce plots and
#' descriptive statistics.
#'
#' @param operate A vector of ID codes.
#' @param crl A vector of crl data.
#' @param nt A vector of nt data.
#' @param ref.coef Reference coefficient for gestational age.
#' @param ... Further arguments passed to or from other methods.
#'
#' @export
my_fn <- function (operate,
crl,
nt,
ref.coef = list(fit = function(crl) {
-1 + 0.05 * crl - 0.0002 * crl ^ 2
},
sd.reg = 0.5),
...) {
# Some cool stuff
}
对应的.rd文件如下:
% Generated by roxygen2 (4.1.1): do not edit by hand
% Please edit documentation in R/my_fn.R
\name{my_fn}
\alias{my_fn}
\title{My function}
\usage{
my_fn(operate, crl, nt,
ref.coef = list(fit = function(crl) { -1 + 0.05 * crl - 0.0002
* crl^2 }, sd.reg = 0.5), ...)
}
\arguments{
\item{operate}{A vector of ID codes.}
\item{crl}{A vector of crl data.}
\item{nt}{A vector of nt data.}
\item{ref.coef}{Reference coefficient for gestational age.}
\item{...}{Further arguments passed to or from other methods.}
}
\description{
Extracts data from the database in order to produce plots and
descriptive statistics.
}
有什么失败的地方吗?
当我从文档和函数中删除整个 ref.coef
时,没有错误。
当我将它保存在 roxygen 文档和函数中时,对其进行 roxygenize,然后尝试添加 sd.reg
(看看它是否只是一个解析错误)它仍然抱怨。
它看起来不像是 roxygen 问题,但更像是 R CMD check
处理 Rd 文件的方式。
临时解决方案可能是执行以下操作:
ref.coef = REF.COEF(),
然后
REF.COEF <- function() {
list(fit = function(crl) {
-1 + 0.05 * crl - 0.0002 * crl ^ 2
},
sd.reg = 0.5)
}
(所以你得到一个 good/passing R CMD check
并且仍然得到你需要的功能)
并在 R 开发列表上发布有关您的错误的消息。这可能是一个简单的 Rd 解析问题(但您可能还想考虑稍微简化函数参数并在函数与参数中进行列表赋值)。
我无法让我的包裹通过 R CMD 检查。我正在使用 devtools
版本 1.9.1 和 Roxygen2
版本 4.1.1。我遇到的问题如下:
Bad \usage lines found in documentation object 'my_fn':
Functions with \usage entries need to have the appropriate \alias
entries, and all their arguments documented.
The \usage entries must correspond to syntactically valid R code.
See chapter 'Writing R documentation files' in the 'Writing R
Extensions' manual.
正如您所见,它实际上并没有给我任何关于问题发生位置的指示。就是2个空格。
我的函数如下:
#' My function
#'
#' Extracts data from the database in order to produce plots and
#' descriptive statistics.
#'
#' @param operate A vector of ID codes.
#' @param crl A vector of crl data.
#' @param nt A vector of nt data.
#' @param ref.coef Reference coefficient for gestational age.
#' @param ... Further arguments passed to or from other methods.
#'
#' @export
my_fn <- function (operate,
crl,
nt,
ref.coef = list(fit = function(crl) {
-1 + 0.05 * crl - 0.0002 * crl ^ 2
},
sd.reg = 0.5),
...) {
# Some cool stuff
}
对应的.rd文件如下:
% Generated by roxygen2 (4.1.1): do not edit by hand
% Please edit documentation in R/my_fn.R
\name{my_fn}
\alias{my_fn}
\title{My function}
\usage{
my_fn(operate, crl, nt,
ref.coef = list(fit = function(crl) { -1 + 0.05 * crl - 0.0002
* crl^2 }, sd.reg = 0.5), ...)
}
\arguments{
\item{operate}{A vector of ID codes.}
\item{crl}{A vector of crl data.}
\item{nt}{A vector of nt data.}
\item{ref.coef}{Reference coefficient for gestational age.}
\item{...}{Further arguments passed to or from other methods.}
}
\description{
Extracts data from the database in order to produce plots and
descriptive statistics.
}
有什么失败的地方吗?
当我从文档和函数中删除整个 ref.coef
时,没有错误。
当我将它保存在 roxygen 文档和函数中时,对其进行 roxygenize,然后尝试添加 sd.reg
(看看它是否只是一个解析错误)它仍然抱怨。
它看起来不像是 roxygen 问题,但更像是 R CMD check
处理 Rd 文件的方式。
临时解决方案可能是执行以下操作:
ref.coef = REF.COEF(),
然后
REF.COEF <- function() {
list(fit = function(crl) {
-1 + 0.05 * crl - 0.0002 * crl ^ 2
},
sd.reg = 0.5)
}
(所以你得到一个 good/passing R CMD check
并且仍然得到你需要的功能)
并在 R 开发列表上发布有关您的错误的消息。这可能是一个简单的 Rd 解析问题(但您可能还想考虑稍微简化函数参数并在函数与参数中进行列表赋值)。