rquotenoweb

How to quote an Rscript call?


My goal is to call Rscript from an .Rnw file via SweavePDF, set up as follows:

(add-hook 'Rnw-mode-hook
      (lambda ()
        (add-to-list 'TeX-command-list
             '("SweavePDF" "Rscript -e 'patchDVI::SweavePDF('%t', encoding='utf8')'"
               TeX-run-command nil t :help "Run SweavePDF") t)
        (setq TeX-command-default "SweavePDF")))

How can the R script Rscript be called correctly? Something with the quotes seems to not work as expected:?

Running `SweavePDF' on `ch03_copula' with ``Rscript -e 'patchDVI::SweavePDF('ch03_copula.Rnw', encoding='utf8')''
/bin/sh: 1: Syntax error: Unterminated quoted string

SweavePDF exited abnormally with code 2 

Solution

  • Just found out that double-quotes can be escaped with backslash \"