R 错误\在文档对象中找到用法行

R 错误\在文档对象中找到用法行,r,roxygen2,R,Roxygen2,我的包裹无法通过R CMD检查。我正在使用devtoolsversion1.9.1和Roxygen2version4.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

我的包裹无法通过R CMD检查。我正在使用
devtools
version1.9.1和
Roxygen2
version4.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.
#' 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
}
% 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.
}
所以,正如你所看到的,它实际上并没有给我任何关于问题发生地点的指示。只有两个空格

我的职能如下:

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.
#' 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
}
% 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)
}

REF.COEF SD.reg不在@param中,但
SD.reg
不是一个参数,它是名为
REF.COEF
的列表的一部分。我尝试为
SD.reg
fit
添加
@param
标记,但我得到了完全相同的问题。谢谢@hrbrmstr,我将尝试一下。这很奇怪,因为我有另一个函数,它与这个函数非常相似,它也以同样的方式使用
ref.coef
参数,但我对这个参数没有任何问题……可能是某种深奥的组合导致Rd解析器发疯。如果我今天有更多的周期(我有几个“监听”的骗局电话),我会看看所说的组合可能是什么。