【问题标题】:variable names are limited to 256 bytes变量名限制为 256 个字节
【发布时间】:2011-04-25 21:03:23
【问题描述】:

roxygenize 在以下代码上失败,并显示以下错误消息。关于这个主题的其他帖子表明有一个错位的字符。我找不到任何问题!你能发现问题吗?

#' My Title. My Description
#'
#' @return A n x n \code{\link{matrix}} where n = the number of variables.  Row and column names are in the same order and are equivalent to the variable names in \samp{timeSeriesData}.  Each entry [i,j] in the matrix is the covariance between variable i and variable j.
#' @callGraphPrimitives
#' @note some notes here
MyFunc = function( timeseriesData ,  method , decayFactor  )
{
}


Error in do.call(paste, c(trimmed.lines, sep = "\n")) :
  variable names are limited to 256 bytes
Calls: roxygenize ... parse.ref.list -> append -> parse.ref -> parse.ref.preref
-> do.call
Execution halted

编辑1
如果我从长 @return 行中取出几个单词,上面的代码就可以正常工作

编辑2
在 roxygenize 调用之前添加 sessionInfo() 结果。

R version 2.12.2 (2011-02-25)
Platform: i386-pc-mingw32/i386 (32-bit)

locale:
[1] LC_COLLATE=English_United States.1252
[2] LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C
[5] LC_TIME=English_United States.1252

attached base packages:
[1] stats     graphics  utils     datasets  grDevices methods   base

other attached packages:
[1] roxygen_0.1-2 digest_0.4.2

【问题讨论】:

  • 这在我的机器上运行没有任何错误。 sesionInfo() 的结果是什么?
  • 我在 roxygenize 调用之前发布了 sessionInfo。在 roxygenize 调用后我无法让它工作,因为执行停止。请注意,如果您从@return 行的末尾取出几个单词,则原始代码可以正常工作。
  • 这是一个猜测:@return 参数限制为 256 个字符。也许我过去遇到过同样的问题,因为通常我的@return 包含像@return data.frame 这样的最小内容。相反,我倾向于使用 roxygen 描述来扩展机制和输出。仅供参考,您缺少 @param 调用 - 如果您打算在包中使用此函数,如果您的 @param 和函数参数不匹配,R CMD 检查将失败。
  • @Andrie - 是的,我取出@param 只是为了减少代码。我想您对@return 的看法是正确的……如果能得到一个实际上是限制的明确答案,那就太好了。
  • @Andrie - 啊...刚刚看到@Henry 的回答

标签: r roxygen


【解决方案1】:

这是一个已知错误:请参阅this discussion,其中涉及 roxygen 的贡献者 Hadley Wickham。

解决方法是缩短行:#' @return A n x n ... 行中有大约 270 个字符(包括三个句子),因此可以轻松拆分。

【讨论】:

  • +1 也是。当您说“拆分”时,您的意思是我可以保留内容并将其拆分为多行?
【解决方案2】:

另一个可能的解决方案是升级到 R2.13.0,现在您的字符长度最大值为 10.000 而不是 256

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-09-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-02-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多