[ESS] Fwd: Re: [R] .Rd vs. .R, was: matrix multiplication

Vitalie Spinu spinuvit at gmail.com
Mon Dec 17 01:37:40 CET 2012


  >> Christian Hoffmann <c-w.hoffmann at sunrise.ch>
  >> on Thu, 06 Dec 2012 14:29:02 +0100 wrote:

  CH> (1)> I am interested in commissioning lines, functions, regions for execution
  CH> from .Rd using ^C-^F, ^C-^R, ^C-^J,  as one can do from .R files. In that way I
  CH> would be able to check my \examples in .Rd  directly. Where can this be switched
  CH> on?

C-c C-c, C-M-x, C-c r are on in .Rd buffers. Anything else you can add
to Rd-mode-map.


  CH> (2)  I find it cumbersomesome that  I have to use \%*\% in .Rd files vs. %*% in
  CH> .R files. R CMD check will refuse %*% in .Rd files, because it thinks there is a
  CH> comment. I would like to have  %*% in \examples of an .Rd files to be able to
  CH> execute expressions with matrix  multiplication from .Rd files directly, but ESS
  CH> (version 5.13) would  refuse to execute this execution, see (1).   What can be
  CH> done here?

In the development version of ESS there is a non-standard hook
ess-presend-filter-functions. You can add to it locally in Rd-mode:


   (defun my-substitute-% (str)
     (replace-regexp-in-string "\\\\%" "%" str))
   
   (add-hook 'Rd-mode-hook
             (lambda () (add-hook  'ess-presend-filter-functions
                                   'my-substitute-% nil t)))
   
This substitutes \% with %, only in code submissions from Rd buffers.

    Vitalie



More information about the ESS-help mailing list