Clark
Clark

Reputation: 43

Documenting multiple related S4 methods in single file with roxygen2

I have two S4 methods (pw_indep(), gw_indep()) that are closely related, and I would like to document them together using roxygen2 (in RStudio). They reside in R/indep.R of my package.

Here's an MWE mockup of what I tried so far:

#' Add independence constraints for base terms
#'
#' @description `pw_indep()` returns "PAIRWISE".
#'
#'   `gw_indep()` returns "GROUPWISE".
#'
#' @param cst Object of class `Probabilities`.
#' @param ... Base terms.
#'
#' @return A string.
#' @docType methods
#' @name indep
#' @aliases pw_indep,gw_indep
NULL
#> NULL

########## Pairwise independence ##########
#' @rdname indep
#' @method Probabilities pw_indep
#' @export

setGeneric(
  "pw_indep",
  function(cst, ...) standardGeneric("pw_indep")
)

setMethod(
  "pw_indep",
  "Probabilities",
  function(cst, ...){
    return("PAIRWISE")
  }
)

########## Groupwise independence ##########
#' @rdname indep
#' @method Probabilities gw_indep
#' @export

setGeneric(
  "gw_indep",
  function(cst, ...) standardGeneric("gw_indep")
)

setMethod(
  "gw_indep",
  "Probabilities",
  function(cst, ...){
    return("GROUPWISE")
  }
)

Building the documentation works fine, and I can access it using ?indep and ?gw_indep. However, I cannot get ?pw_indep to work ("no documentation found" error).

I don't quite understand why this fails. Any help would be appreciated!

Upvotes: 2

Views: 32

Answers (0)

Related Questions