2

I have an R6 class myclass, and I have defined the S3 generic as.matrix for it. Everything works, but I'm getting 2 notes when I run R CMD check:

Note 1:

  S3 methods shown with full name in documentation object 'as.matrix.myclass':
    'as.matrix.myclass'

  The \usage entries for S3 methods should use the \method markup and not
  their full name.
  See chapter 'Writing R documentation files' in the 'Writing R
  Extensions' manual.

Note 2:

Found the following apparent S3 methods exported but not registered:
    as.matrix.myclass
  See section 'Registering S3 methods' in the 'Writing R Extensions'
  manual.

Here is how I have my S3 generic defined and documented (this is outside the R6 class):

#' Converts all cores to R matrices
#'
#' @param x \code{myclass}
#' @param ... other arguments passed to \code{as.matrix()}
#' @return A named list of R matrices.
#' @export

as.matrix.myclass <- function(x, ...) {
  sapply(
    x$cores,
    function(x, ...) as.matrix(x, ...),
    USE.NAMES = TRUE, simplify = FALSE
  )
}

I'm using a newer version of roxygen that supports R6 documentation, but I can't find any info on how to get rid of these notes. Thanks!

Kyle Ward
  • 889
  • 1
  • 8
  • 18
  • I would have thought it was bad form to write an `as.matrix` method that does not return a matrix. That's surely inviting problems for the end-user. Why use the generic at all if your method is not sticking to the "rules" of what the generic is supposed to do? – Allan Cameron Nov 17 '20 at 18:57
  • 2
    I'm unable to reproduce this with roxygen2 version 7.1.1 -- does upgrading fix your problem? – Mikko Marttila Nov 18 '20 at 14:40

1 Answers1

2

As @Mikko suggested, I updated my version of roxygen (my original post is fairly old now). In 7.1.1, I no longer get the note. Thanks!

Kyle Ward
  • 889
  • 1
  • 8
  • 18