Using knitr and RMarkdown from RStudio

Using knitr and RMarkdown from RStudio

The analyses I run using R I usually use RStudio for, as it has a rather good support for project handling with a git connection as well as direct access to knitr and RMarkdown. Usually I report the results of the analysis as html file, with foldable code-chunks and figures stored on the HDD separately. For that, my standard header of any analysis in R looks like this:

[shell]

title: “Here comes the title”
subtitle: Something for the subtitle
author: “Daniel Fischer”
date: “22 March 2017”
output:
html_document:
code_folding: hide
theme: paper
toc: yes
toc_float:
collapsed: yes
smooth_scroll: no
pdf_document:
keep_tex: yes
abstract: Summary of the latest analysis steps

# Project Parameters

“`{r setup}
library(“rmarkdown”)
library(“knitr”)
library(“xtable”)
knitr::opts_chunk$set(echo = TRUE)
projFolder <- “/home/daniel”
opts_chunk$set(tidy=TRUE,
echo=TRUE,
warning=FALSE,
message=FALSE)
opts_knit$set(base.dir=projFolder)
opts_chunk$set(dev=c(“png”,”pdf”),
fig.path=paste(projFolder, “Figures/”,sep=””))
options(stringsAsFactors = FALSE)
“`
[/shell]

Back to: Introduction to R – Overview

Leave a Reply