[ESS] Allow \%*\% to be evaluable in Examples in *.Rd [FWD]

Martin Maechler maechler at stat.math.ethz.ch
Tue Dec 4 08:57:14 CET 2012


This (mail from R-help, see at the bottom) is an interesting
suggestion from a ESS-non-lover (and R core member)

Christian on one hand is right insofar that it is a bit painful that
in ESS, you cannot send  example code containing \%*\% directly
to R,  and
Duncan Murdoch is right of course that ESS could be tweaked to
handle this directly.

Of course, one could argue that Christian should just learn to
first use   C-c C-p  (Rd preview)
and then  on the page skip to the Examples section (via 's e')
and evaluate the example code (in the usual "help mode way").

Still I agree it would be really neat and convenient (for me
too, as maintainer of the Matrix package!) if this case worked
directly from *.Rd.

I think the improvement could easily be made to 
also work for   '%%'  '%/%'  '%o%' and '%in%'  by possibly using
something like

	     replace   \\%\([-+*/^a-zA-z]{0,3}\)\\%  by   %\1%

	     ((I think the regexp should be general, but not too general,
	       lest we will get FALSE positives that will be a PITA))

Patches very welcome!

Martin



------- start of forwarded message -------
From: Duncan Murdoch <murdoch.duncan at gmail.com>
To: Christian Hoffmann <c-w.hoffmann at sunrise.ch>
CC: <R-help at r-project.org>
Subject: Re: [R] .Rd vs. .R, matrix multiplication
Date: Mon, 3 Dec 2012 18:17:52 -0500
In-Reply-To: <50BD20E5.2070805 at sunrise.ch>

On 12-12-03 5:00 PM, Christian Hoffmann wrote:
> Hi,
>
> I find it cumbersomesome the I have to use \%*\% in .Rd files vs. %*% in
> .R files. R CMD check will refuse %*% in .Rd files. I would like to have
> %*% in .Rd files to be able to execute expressions with matrix
> multiplication from .Rd files directly, but ESS (version 5.13) would
> refuse to execute this execution.
>
> What can be done here?
>

That sounds like a problem that ESS could solve.  The rules for what 
needs escaping in .Rd files are well defined, and ESS should know what 
kind of file it is editing, so it should be fixable.

Allowing raw %*% in a .Rd code block would mean that invisible comments 
were impossible (since Rd comments start with %).  They are not 
extremely common, but common enough that it would inconvenience a lot of 
package writers to make that change.  Seems like a small ESS fix is easier.

Duncan Murdoch

______________________________________________
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.
------- end of forwarded message -------



More information about the ESS-help mailing list