[R] Rd file processing suggestion - % sign in examples

From: Peter Langfelder <peter.langfelder_at_gmail.com>
Date: Mon, 18 Apr 2011 23:26:35 -0700

Hi folks,

I have come across a simple quirk that took me a long time to figure out. The gist is that if I write, in the example section of an Rd file, the line

c = a %*% b

what R will see when running the example is

c = a

since the % signs are apparently considered comment signs even in the \examples section. The change from c = a %*% b to c = a can easily make the example code fail with an error further down the line. The thing is, if you take the code and copy-paste it into a standard R session, the code will run correctly (which is what happened to me and it took me several hours to figure this mystery out). The solution is to escape the % signs by a backslash, i.e. to write c = a \%*\% b

The suggestion is (of course) to make the Rd processor/parser not consider % sign a comment sign in the examples section. Hopefully that wouldn't be too difficult...



R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Tue 19 Apr 2011 - 06:29:04 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 19 Apr 2011 - 07:40:31 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive