In another post I have already talked about different topics not directly associated to Statistic. At this time I will write about reports combining the use of R and Latex. Specifically about how to export tables to Latex and insert latex typesetting in R figures.

Obviously our technical work is very important but the final presentation which should be taken care of. Sometimes the problem is to move our results from the statistical software to the text editor so I will talk in this post about my favourite tools to perform this task.

When looking for a text editor to do a report, there are may options to choose between (MS Word, Latex, knitr/Sweave, Markdown, etc.). I pick out Latex versus MS Word given its possibility to easily include math language. The connection between knitr/Sweave and Markdown with R is straightforward (these two software imbibe R code), in future posts I will talk about them.

**R tables to Latex**

As I commented I first work with R and then move the results to Latex. One of the simplest and most effective tools is the function *xtable()* that we can find in the package of the same name, xtable.

*xtable()*, this function creates the code that we write in latex from an R table.

Other important packages in R with extra functionalities to convert object from R to Latex code are:

- Hmisc: you can use the function
*latex()* to create a tex file.

- texreg: highly configurable and designed to convert model summary outputs.

**Figures**

Many people will know the graphics of Latex, called TikZ (see page examples), but what is not so known is that this type of graphics allow a wonderful connection between R and Latex. It allows that formulas, numbers, etc. displayed in the format of choice in Latex. To do this we simply have to follow the next steps:

- In R: Create the tikz images from R using
*tikz()* function, see this, in package tikzDevice ( *install.packages(“tikzDevice”, repos=”http://R-Forge.R-project.org”) *). This function will create a tex file that can be compiled into PDF, but the only thing you need to do is to include the tex file into your Latex document.
- In Latex: Insert in Latex document with function
*\input{normal.tex}* and *\input{symbol-regression.tex}*. The R figure uses directly your format in Latex. You need include on preambule of Latex *\usepackage{tikz}*.

*Will you tell us your “tricks” when making reports?*

### Like this:

Like Loading...

*Related*

Reblogueó esto en Tales of Ry comentado:

Add your thoughts here… (optional)