The lowdown on RMarkdown - R Programming tips and tricks

06-09-2018

Our R expert Mark sheds light on the benefits of RMarkdown

The R programming language (often referred to as "RLang") is becoming
increasingly popular as an analytical solution for businesses and
institutions around the world. R also has powerful graphical
capabilities.

In the past it has been something of a specialist task to get
results from R into other formats, that better suit the needs of your
organisation. Now integrating R into other workflow and systems is being
made simpler with the advent of
RMarkdown.

RMarkdown is a simple text-based interface that allows you to
combine regular text, graphics and tables with the output from R. You
can produce results in several formats, including HTML, PDF and
Microsoft Word.

Because RMarkdown handles the conversion to the chosen
output format you do not need to learn the complexities of Hyper-Text
Markup Language, or LaTeX. This makes things a lot more efficient as
RMarkdown is a
lot simpler than either! Of course if you do
understand HTML and/or LaTeX then you can incorporate additional code to
your documents.

With RMarkdown you can integrate R-generated analyses and
graphics into reports and other documents. You can also produce
presentations in several formats, such as:

ioslides

Slidy

reveal.js

Beamer

The RMarkdown files themselves are simple to produce, as they can be written in any text editor. Many people turn to RStudio
for producing RMarkdown as it combines a text editor with other tools
to help streamline the process of making your RMarkdown text into the
output you want.

RMarkdown makes it easy to reproduce analytical results,
generated by R code, in your output documents. You can present the
details easily and efficiently using a range of tools. The following is a
simple example of a regression analysis:

Df

Sum Sq

Mean Sq

F value

Pr(>F)

wool

1

450.667

450.667

3.765

0.058

tension

2

2034.259

1017.130

8.498

0.001

wool:tension

2

1002.778

501.389

4.189

0.021

Residuals

48

5745.111

119.690

NA

NA

RMarkdown takes care of the basic formatting for you and
allows you to focus on producing your report and getting across the
message, rather than tinkering with the transfer from R to Word or HTML.

Similarly, with graphics you can focus on the graphic you want
right from the RMarkdown document and do not have to step through a
complicated process of generating a graphic, exporting it to disk,
importing it to a new document. The following box-whisker plot is an
example of a graphic generated from R (it is based on the regression
results shown earlier):

You have all the control over your graphics that you expect from
R, but are able to have the result directed to your HTML, PDF or Word
document with minimal fuss.

In the examples shown here the R code is "hidden" but if you need
to get technical you can easily show the code, and have some control
over the syntax highlighting too.

We recognise that your time is valuable so we've put together an
introductory course in RMarkdown. In this one-day course you will learn:

The basics of Markdown

Incorporating R code

How to make different documents such as:

HTML documents

Microsoft Word documents

PDF documents

How to create presentation output:

in HTML5 format

in PDF format

Along the way you will discover various aspects of RMarkdown including:

Adding hyperlinks

Text formatting styles

Using numbered and bullet lists

Using graphics

Including tables

Creating tables of contents

Tweaking themes and templates

...In short, we'll help you gain the practical skills to produce a variety
of output right away and to incorporate your R output seamlessly into
your work.