I have a custom class, called "FOO", and would like to set the "length" method for that class. Here is a template:
#' Returns the length of the FOO object
#'
#' @name length
#' @param x a FOO object
#' @aliases XXX
#' @rdname YYY
#' @docType methods
setMethod("length", "tmod",
function(x) {
nrow(x$BLAH)
})
The method itself works correctly.
bar <- list(BLAH=1:10)
bar <- as(bar, "FOO")
length(bar)
...returns 10.
My question: what should be entered instead of "XXX" and "YYY"? The entry on documenting S4 methods and classes in "Writing R extensions" is a bit on the short side, to put it mildly. Documentation of roxygen2 is using made up examples. But what should I do if I want to use a generic which was not defined by me?
Note that the difference between, say, this question is that I am specifically asking about defining the "length" method which corresponds to a function from the base package. This is quite different from the "show" for which a "show-methods" manual page already exists.