12.5 MS Word via knitr/R Markdown

When moving from a .R file to a Markdown (.Rmd) file, environment objects such as tables or data frames / tibbles usually require to be saved and loaded to R Markdown document.

In RStudio, select:
File > New File > R Markdown

A useful template file is produced by default. Try hitting knit to Word on the knitr button at the top of the .Rmd script window. If you have difficulties at this stage, refer to chapter 11.

Now paste this into the file:

The result is ok, but not great (Figure 12.2A).

Knitting to Microsoft Word from R Markdown. Before (A) and after (B) adjustment.

FIGURE 12.2: Knitting to Microsoft Word from R Markdown. Before (A) and after (B) adjustment.