2

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?

Migwell
  • 18,631
  • 21
  • 91
  • 160
  • I'd try escaping it with a backslash, `#' \[[,Myclass-method]` (or maybe 2) – Gregor Thomas Apr 06 '21 at 02:52
  • If I use the backslash to escape the second bracket ie `[\[,MyClass-method]`, then I get `\item [[,MyClass-method]`. If I escape the first racket `\[[,MyClass-method]` I get `[\link{,HistDat-method}`. Neither is right, though. The correct output would be `\link{[,HistDat-method}`. – Migwell Apr 06 '21 at 05:36

0 Answers0