Compiling Woven R code (RNW files) using Sweave or Knitr
This article concerns the
macOS
app.
See other variants:
Windows

The RNW files

R code can be woven with LaTeX in the form of RNW files that carry the .rnw extension. These can be processed using two main tools, knitr and sweave. Texifier allows you to work with .rnw files, edit them, convert them quietly into .tex files using R and typeset the resulting .tex into a PDF. Please note that currently this is only supported in the External typesetter on macOS.

When using auto-sense typeset configuration (i.e., the default option when opening a .rnw file for the first time), Texifier will automatically pick the correct flavour and typeset the PDF for you. As always, you can customise this in the manual mode of the typeset configuration,

docs/apps/workspace/typesetting/config/manual-woven-r_macos.png

This is accessible via the settings button in the typeset bar above the editor.

Installing R and knitr

As knitr appears to us from the feedback of our users the more popular choice, we’ll comment a little more on it.

R and its packages that enable .rnw files to work are not part of the TeX distribution. In order to work with .rnw files, both R and knitr must first be installed first. Please visit their respective websites and look for instructions on how to install them:

Examples of .rnw files that use knitr may be viewed at the official Github repository at

https://github.com/yihui/knitr/blob/master/inst/examples/knitr-minimal.Rnw

Further Notes

Although, Texifier is designed to handle .rnw while the option “Hide intermediate files” is on, in some cases this may have to be turned off:

docs/apps/workspace/typesetting/config/hide_intermediate_files_off_macos.png