1

I wrote a method for a generic S4 function in R. The name of the generic function is extract. The class the method refers to has a hyphen in it, as in Zelig-tobit models. I'd like to write a documentation entry for the method as follows in the usage section of the respective .Rd file:

\S4method{extract}{Zelig-tobit}(model, ...)

If I do that, R CMD check --as-cran returns an error message:

* checking Rd \usage sections ... WARNING
Bad \usage lines found in documentation object 'extract':   
  <unescaped bksl>S4method{extract}{Zelig-tobit}(model, ...)

How do I correctly escape the hyphen?

Daniel Widdis
  • 8,424
  • 13
  • 41
  • 63
Philip Leifeld
  • 2,253
  • 15
  • 24
  • Only suggestion is to use quotation marks: `{"Zelig-tobit"}`, does this give a different error? – MichaelChirico May 02 '16 at 19:28
  • (although [the manual](https://developer.r-project.org/parseRd.pdf) suggests "Quotes ", 'and ` have no syntactic relevance within LaTeX-like text.", which is what `S4method` is grouped under...) – MichaelChirico May 02 '16 at 19:33
  • Thanks for your comment. Yeah, I tried both single and double quotation marks, but this produces the same error message... – Philip Leifeld May 02 '16 at 19:35
  • Does `Zelig_tobit` compile, at least? And `Zeligtobit` – MichaelChirico May 02 '16 at 19:48
  • 1
    I have found a solution that works for me: Zelig models always have a specific class name (e.g., ``Zelig-tobit``) and a general class name (i.e., ``Zelig``). I am combining multiple extract methods in one ``extract.Zelig`` method and I'm using an if condition on the class name vector to determine which sub-model was estimated. While this works in my specific case, however, I would still be interested in a more general solution to this problem. That is, how can hyphens be escaped in usage sections of .Rd files? – Philip Leifeld May 02 '16 at 21:25

0 Answers0