Escaping hyphen in S4 method in Rd usage section in R package documentation
Asked Answered
T

0

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?

Tarahtaran answered 1/5, 2016 at 17:16 Comment(5)
Only suggestion is to use quotation marks: {"Zelig-tobit"}, does this give a different error?Waadt
(although the manual suggests "Quotes ", 'and ` have no syntactic relevance within LaTeX-like text.", which is what S4method is grouped under...)Waadt
Thanks for your comment. Yeah, I tried both single and double quotation marks, but this produces the same error message...Tarahtaran
Does Zelig_tobit compile, at least? And ZeligtobitWaadt
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?Tarahtaran

© 2022 - 2024 — McMap. All rights reserved.