【问题标题】:How to document an R generic defined in an IF statement如何记录在 IF 语句中定义的 R 泛型
【发布时间】:2021-02-09 22:13:35
【问题描述】:

我有一个在 IF 语句中设置的 R 泛型:

if (is.null(getGeneric("isIdCurrent"))) {
  setGeneric("isIdCurrent", function(dbObj, ...) standardGeneric("isIdCurrent"))
}

如果我不记录它,RStudio“检查”会抱怨“未记录的代码对象”。但是如果我尝试记录它(roxygen2 v7.1.1),例如:

if (is.null(getGeneric("foo"))) {
#' @rdname myGnrc
  setGeneric("foo", function(dbObj, ...) standardGeneric("foo"))
}

RStudio“清理并重建”会抱怨“@rdname Missing name”。

如果我删除 IF 语句,那么我的所有问题当然都解决了:

#' @rdname myGnrc
setGeneric("foo", function(dbObj, ...) standardGeneric("foo"))

但我正在尝试维护其他人的代码,我不确定删除 IF 语句是否安全。

任何帮助将不胜感激!

【问题讨论】:

    标签: r generics roxygen2


    【解决方案1】:

    经过一番阅读和实验,我认为删除 IF 语句是安全的。

    【讨论】:

      猜你喜欢
      • 2016-02-07
      • 2021-10-29
      • 1970-01-01
      • 2019-05-28
      • 2020-09-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多