我很难得到我的包裹,以通过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.所以,正如你所看到的,它实际上并没有给我任何关于问题在哪里发生的指示。只有两个空格。
我的职能如下:
#' 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.
}有什么好主意吗?
发布于 2015-10-28 12:25:10
当我从文档和函数中删除整个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)
}(因此,您获得了一个良好的/传递的R CMD check,并且仍然获得了所需的功能)
并在R发展列表上发布关于您的错误的消息。这可能是一个简单的Rd解析问题(但您可能还想考虑简化一些函数params,并在函数和param中执行列表分配)。
https://stackoverflow.com/questions/33390521
复制相似问题