如何正确定义和记录! S4类的方法

时间:2017-04-28 21:36:53

标签: r devtools s4 roxygen2

我正在尝试为自定义S4类定义!方法。让我们说它看起来像(R/foo.R

#' Foo
#'
#' @param is_true logical
#' @export
setClass("Foo", slots = list(is_true = "logical"))

#' !
#'
#' Negates Foo
#'
#' @param x Foo
#'
#' @rdname !
#' @name !
#' @aliases !,Foo-method
#' @importFrom methods new
#' @examples
#' !new("Foo", is_true = FALSE)
#' @export
setMethod(
  "!", signature(x = "Foo"),
  function(x) { new("Foo", is_true = !x@is_true) }
)

DESCRIPTION

Package: foo
Title: What the Package Does (one line, title case)
Version: 0.0.0.9000
Authors@R: person("First", "Last", email = "first.last@example.com", role = c("aut", "cre"))
Description: What the package does (one paragraph).
Depends:
    R (>= 3.3.3)
License: What license is it under?
Encoding: UTF-8
LazyData: true
RoxygenNote: 5.0.1
Imports: methods

但是当我跑devtools::check时,我得到了:

Undocumented S4 methods:
  generic '!' and siglist 'Foo'
All user-level objects in a package (including S4 classes and methods)
should have documentation entries.

有谁可以解释我在这里缺少的东西?

调整@rdname

@rdname Foo

似乎部分地解决了这个问题,但又引入了另一个问题:

* checking Rd files ... WARNING
prepare_Rd: Foo.Rd: \name should not contain !, | or @

是什么让我觉得这不是可行的方法,虽然生成的rd文件看起来很好。

0 个答案:

没有答案