The workflow for building a LaTeX-based report is very similar to creating Markdown or HTML reports, but of course you need to know how to work with LaTeX. Create a new .Rnw
file through File | New | R Sweave. RStudio will open a LaTeX template in the article document format. Code chunks are delimited by the <<>>=@
syntax (see the Code chunks section for options) and you can compile the .Rnw
file to pdf
via File | Compile pdf, by clicking on the PDF menu button on the file editor tab, or by hitting Ctrl + Shift + I. Inline R code should be enclosed in the \Sexp{}
command. Here's a minimal example of a .Rnw
file and its result:
\documentclass{article} \begin{document} One plus one according to \texttt{R}: <<>>= 1+1 @ \end{document}
This results in the following pdf
file:
The extensive example given in the section on Markdown is also available in a LaTeX version from the github repository, go to https://github.com/rstudiobook/abalone.git.