R Markdown reports

Writing R Markdown in DSS

R Markdown reports can be used to generate documents based on your project’s data.

R Markdown is an extension of the markdown language that enable you to easily mix formatted text with code written in several languages (in particular R or Python).

When editing your R Markdown report, you can “build” it to generate the output document. This document can be displayed as HTML and published into a dashboard. You can download the output document in various formats including:

  • html
  • pdf
  • Microsoft Word (docx)
  • OpenDocument (odt)
  • Markdown (or plain text)

Creating an R Markdown report

You can create a report from the “RMarkdown reports” tab of the “Notebooks” section of DSS.

../_images/rmarkdown_tab.png

Prerequisites

RMarkdown reports can be built in any R code environment. The builtin R environment has the rmarkdown package preinstalled. If you use a custom code environment, you will need to install the rmarkdown package.

Many export formats of RMarkdown require the pandoc system package to be installed. This package pulls a large number of additional dependencies and is not installed by default. You’ll need to ask your system administrator to install the pandoc system package for your Linux server (You need pandoc 1.12.3 or higher). You will also need the the adjustbox, collectbox, ucs, collection-fontsrecommended, and titling LaTeX packages to produce PDF documents.

Note about Python blocks

Be aware that Python blocks in Rmarkdown reports are not run by the built-in DSS Python environement. We would recomand you to create a Python code environment in DSS and force it as the Python environement used by Rmarkdown. For example:

```{r global_options, include=FALSE}
library(knitr)
library(reticulate)
use_python("[data-dir]/code-envs/python/[code-env-name]/bin/python")
knitr::knit_engines$set(python = reticulate::eng_python)
matplotlib <- import("matplotlib")
matplotlib$use('Agg')
```

```{python, engine.path="[data-dir]/code-envs/python/[code-env-name]/bin/python", echo=FALSE}
import seaborn
import pandas as pd
print(dir(seaborn))
```

Getting started

Go through our tutorial to create your first R Markdown report.