[R-pkg-devel] How to Document and S3 Method for the Parenthesis Class?

biii m@iii@g oii de@@ey@ws biii m@iii@g oii de@@ey@ws
Thu Nov 7 16:47:57 CET 2019


That's fair, though it's not 100% consistent because code like the following works for symbols, too:

"(\\@" <- 1

(This is selected to show how bad things can be done-- not as an example to advocate.)

-----Original Message-----
From: Jeff Newmiller <jdnewmil using dcn.davis.ca.us> 
Sent: Thursday, November 7, 2019 10:43 AM
To: r-package-devel using r-project.org; bill using denney.ws
Subject: Re: [R-pkg-devel] How to Document and S3 Method for the Parenthesis Class?

There are three types of quoting in R... " and ' are for strings, and ` (backtick) is for symbols.

On November 7, 2019 6:35:49 AM PST, bill using denney.ws wrote:
>Hi,
>
> 
>
>Short version of the question:  How does one document a method for the 
>"("
>class in a .Rd file?
>
> 
>
>Details:
>
>I recently contributed to the digest package functions to assist with 
>generating sha1 hashes for formula objects.  Sometimes within formula, 
>the parenthesis ("(") class is used, for example [1]:
>
> 
>
>> class((a~(b+c))[[3]])
>
>[1] "("
>
> 
>
>So, I wrote a method to handle that class, too.  When trying to 
>document it in the .Rd file, I tried the following code, but when 
>checking the documentation, it gets an error:
>
> 
>
>\method{sha1}{"("}(x, digits = 14, zapsmall = 7, ..., algo = "sha1")
>
> 
>
>The error when checking the documentation is:
>
> 
>
>> checking Rd \usage sections ... WARNING
>
>  Bad \usage lines found in documentation object 'sha1':
>
>   <unescaped bksl>method{sha1}{"("}(x, digits = 14, zapsmall = 7, ..., 
>algo = "sha1")
>
>  
>
>  Functions with \usage entries need to have the appropriate \alias
>
>  entries, and all their arguments documented.
>
>  The \usage entries must correspond to syntactically valid R code.
>
>  See chapter 'Writing R documentation files' in the 'Writing R
>
>  Extensions' manual.
>
> 
>
>I have tried variants of escaping the parenthesis like "\(" and "\\("
>and
>the unescaped variant "(", too.
>
> 
>
>Thanks,
>
> 
>
>Bill
>
> 
>
>[1] In case the first thought is, "don't write formula which have a 
>full side within redundant parentheses", something equivalent to this 
>was created by update.formula().
>
>
>	[[alternative HTML version deleted]]
>
>______________________________________________
>R-package-devel using r-project.org mailing list 
>https://stat.ethz.ch/mailman/listinfo/r-package-devel

--
Sent from my phone. Please excuse my brevity.



More information about the R-package-devel mailing list