【问题标题】:building R packages--Error : example requires a value构建 R 包——错误:示例需要一个值
【发布时间】:2014-05-01 09:29:02
【问题描述】:

当我构建我的包时,我收到了这个错误。您能帮我了解避免此错误的步骤吗?

#' Square a number
#' 
#' Takes in any numeric value and squares it
#' @param x A value to be squared
#' @return The square of the input
#' @export
#' @example 
square <- function(x)
{
  return(x^2)
}

这是我按下构建时的错误:

==> roxygenize('.', roclets=c('rd', 'collate', 'namespace'))

* checking for changes ... ERROR

Error : example requires a value

【问题讨论】:

  • 您没有在@examples 部分提供任何示例。尝试添加例如#' square(2) 在该行下方。或者,完全删除 @examples 关键字。
  • 我想我应该有那一行来完成我的任务。我正在使用更简单的功能自己学习 roxygen2,但我被卡住了。我应该说写示例(正方形)并得到结果。
  • 然后应用第一个建议。
  • @gagolews 在旁注中,我按照你说的做了,收到了一个错误 ==&gt; roxygenize('.', roclets=c('rd', 'collate', 'namespace')) * checking for changes ... ERROR Error in file(con, "r") : Roclet processing error in block power.r:9 cannot open the connection for #' @example #' square(2) square &lt;- function(x)
  • 那么@examples呢?

标签: r package devtools roxygen2 roxygen


【解决方案1】:

尝试以下方法:

#' @title
#' Square a number
#' 
#' @description
#' Takes in any numeric value and squares it
#'
#' @param x A value to be squared
#' @return The square of the input
#'
#' @export
#' @examples
#' square(2) # 2 squared
square <- function(x)
{
  return(x^2)
}

另外,请确保使用最新的 roxygen2 包。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-06-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-05-27
    • 2011-12-14
    • 1970-01-01
    相关资源
    最近更新 更多