首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >documentation中发现的坏的\使用行

documentation中发现的坏的\使用行
EN

Stack Overflow用户
提问于 2015-10-28 12:01:54
回答 1查看 1.3K关注 0票数 5

我很难得到我的包裹,以通过R,CMD的检查。我使用的是devtools版本1.9.1和Roxygen2版本4.1.1。我的问题如下:

代码语言:javascript
复制
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.

所以,正如你所看到的,它实际上并没有给我任何关于问题在哪里发生的指示。只有两个空格。

我的职能如下:

代码语言:javascript
复制
#' 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文件如下:

代码语言:javascript
复制
% 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.
}

有什么好主意吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-10-28 12:25:10

当我从文档和函数中删除整个ref.coef时,没有错误。

当我将它保存在roxygen文档和函数中时,对其进行roxygenize化,然后尝试添加sd.reg (查看它是否只是一个解析错误),它仍然在抱怨。

它看起来不是roxygen问题,而是R CMD check处理Rd文件的方式。

一个临时的解决办法可能是做如下的事情:

代码语言:javascript
复制
ref.coef = REF.COEF(),

然后

代码语言:javascript
复制
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中执行列表分配)。

票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/33390521

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档