This question was already asked in this stackoverflow question but the accepted answer (download the S4 branch from the author's repository) does not work for me and I think there might be a better way to achieve the same.
I have the following in my file generics.R
:
#' @rdname myfunction-methods
#' @name myfunction <- without this, roxygen2 complaints about missing name
#' @export
methods::setGeneric("myfunction",
function( arg1, arg2 ),
arg3, arg4 {
methods::standardGeneric("myfunction")
});
and then in my file mymethods.R
:
#' Something
#'
#' A brief description
#'
#' @param all params...
#' @return Something
#' @name myfunction <- without this, roxygen2 complaints on missing name
#' @include generics.R
#' @rdname myfunction-methods
#' @export
methods::setMethod( "myfunction",
methods::signature( arg1 = "formula", arg2 = "data.frame" ),
function( arg1, arg2, arg3, arg4 ) {
...whatever
}
)
With this, everything is fine except that the usage
section is not showing up. Could you please correct what is wrong in my documentation? More precisely:
Is it correct to write the documentation before setMethod or is it preferably before setGeneric ?
Why do I need the
@name
in both files? Should it be different? Does it matter?Do I need
@export
in both files?Would
@alias
help at all?
Thank you very much in advance.