How to correctly identify and document! method for S4 clas

I am trying to define a method !

for a custom S4 class. Let's say it looks like ( 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

      

But when I run devtools::check

I get:

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

      

Can anyone please explain what I am not seeing here?

Setting @rdname

:

@rdname Foo

      

seems to partially solve the problem, but introduces another:

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

      

which makes me think this is not the way to go, even though the generated files rd

look great.

+3


source to share





All Articles