RSS

 
  Configuration Component

R-Sweave Changed

-- compatible with WinEdt version(s) 8, 7, 6, 5.5-5.6 --

Support for R, Sweave and knittr:

  • R-support is based on the RWinEdt stuff (menu, highlighting, tool bar buttons). The support is here made available in a standard WinEdt session instead of running it in a limited stand alone WinEdt instance.
  • support (sweave.edt, menu, buttons, ...) for sweave, the R program which transforms LaTeX .Rnw files with R chunks into a LaTeX files with the R chunks replaced by their R outcome.
  • Since version v2.0, support for knitr
  • Since version v2.1, support for inverse search to .Rnw file

For the macro to run correctly, the following R libraries should be installed in your R system:

  • cacheSweave
  • knitr
  • markdown
  • tools
  • stringr

For inverse search you need a PDF reader (such as Sumatra) supporting it. You also need to install Duncan Murdoch's patchDVI R library, which is available from R-Forge with the following R command (needs latest version of R).

install.packages("patchDVI", repos="http://R-Forge.R-project.org")

For sweave, we recommend to transfer the Sweave.sty file from the C:\Program Files\R\R-x.xx.x\share\texmf\ directory to a directory searched by your TeX system. Alternatively, you can add the above directory in the list of paths that TeX will search. In any of these two cases, add a \usepackage{Sweave} in the preamble of your LaTeX document.

Installation

If you had installed a version of R-Sweave prior to v2.2, be sure to delete all related items from MainMenu.ini and from Toolbar.ini before updating.

There are specific zipped distribution files for version WinEdt 7 and WinEdt 8, and for older no longer supported versions, namely WinEdt 6 and WinEdt 5.5. Just select the one which is appropriate for you.

  1. Unpack the file R-Sweave-xx.zip, preferably in an empty folder.
  2. Open WinEdt.
  3. Make a backup of your present configuration (using Options | Maintenance | Backup).
  4. Launch the Install.edt macro (For instance by opening this file in WinEdt and pressing Ctrl-Shift-F9).

In WinEdt 6 and upper, you will have two default drop-down buttons: one for Sweave and knitr, and one for R. This can indeed be customized.

In WinEdt 5.5, you may add R-Sweave related buttons to the Tool Bar through the Enter Tool Bar Setup... dialog (contextual menu from the tool bar). However, you should first restart WinEdt to have access to the R-Sweave buttons.

Default installation is for the 64bit version of R 2.12.0 or higher.

If you have only access to the 32bit version: Before installing, open the MainMenu.ini file (or R-Sweave.dat file for the 5.5 version) provided with the support and substitute in it all occurrences of LetReg(4,'\x64') with LetReg(4,'\i386') or LetReg(4,'') if you have an older version than R 2.12.0.

Usage instructions

You can customize the menu items.

Here are the arguments (registry) that can be passed to the Sweave.edt macro:

LetReg(6,"xxx");
where xxx can be pdf, dvi, Stop or Direct, the latter being an alias of pdf.
LetReg(7,"R installation path");
can be used to tell the macro where it can find the R binaries. If empty, sweave.edt uses the value given by the Windows registry.
LetReg(8,"cache");
for running cacheSweave instead of Sweave.
LetReg(8,"R");
for running Stangle instead of Sweave. Stangle just concatenates all chuncks into a single %n.R file. Indeed when choosing this option, the %!6 register will be ignored.
LetReg(9,"open");
When set Sweave.edt just opens an R console.
LetReg(4,"yyy");
where "yyy" can be either "\i386" (32bit), "\x64" (64bit) if you are running R version 2.12.0 or higher, or "" for R version < 2.12.0.

Arguments that can be passed to knitr.edt are:

LetReg(6,"xxx");
where xxx can be pdf, dvi, R or stop. For files with extension .Rmd or .Rhtml: when not stop or R knit outcome is processed and shown with default application for .html extension.
LetReg(7,"R installation path");
can be used to tell the macro where it can find the R binaries. If empty, sweave.edt uses the value given by the Windows registry.
LetReg(4,"yyy");
where "yyy" can be either "\i386" (32bit), "\x64" (64bit) if you are running R version 2.12.0 or higher, or "" for R version < 2.12.0.

Download

For WinEdt 5.6 or older: R-Sweave-55.zip [31 KB, last changed: 20 Aug 2012]

For WinEdt 6: R-Sweave-6.zip [39 KB, last changed: 23 Nov 2012]

For WinEdt 7: R-Sweave-7.zip [45 KB, last changed: 05 May 2013]

For WinEdt 8: R-Sweave-8.zip [45 KB, last changed: 13 May 2013]

Configuration component contributed by Gilbert Ritschard <gilbert.ritschardunige.ch>, with the help of Karl Koeller <karlkoellergmail.com> for the WinEdt 6/7/8 install macro

  Configuration Component