In my R package, I implemented the [ (indexing) operator for my class:
#' Some title
#' @export
setMethod("[", list(x="MyClass"), function(x, i, j, ...) {
# Some code
})
Now, in the package documentation I want to link to the manual entry for this method. I try the normal way, using methodName,className-method:
#' [[,MyClass-method]
But that just puts a left bracket outside of the \link command in the .Rd file:
[\link{,MyClass-method}
If I try to quote it in some way, I get other issues: I have tried backtick, single and double quotes, and finally doubling the bracket [[ but none of these seem to produce a link that actually works in the final PDF.
How can I cross reference a [ method using Roxygen?
From the "rd-formatting" vignette in
roxygen2(which you can see usingvignette("rd-formatting", package = "roxygen2")):This works for documenting
[, plus other operators, including the "assign" operators/functions that use the "assign" operator,<-. For example,all work. If you want to link to the operator of another package, replace
myPackagewithotherPackage.On the same note, the
roxygen2method of making links like,[levels<-]or[$]will not work for these kinds of links, or if they do, throw notes/warnings when usingdevtools::check()nonetheless.