Skip to content

Instantly share code, notes, and snippets.

Created April 6, 2022 12:36
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
A possible solution to the R-Markdown exercise
title: "A possible solution"
author: "Claudius"
date: "4/6/2022"
toc: yes
toc_float: yes
code_download: yes
theme: "spacelab"
toc: yes
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = FALSE) # Hides code by default
# Introduction
Note that the setup chunk above is not visible in
the final document since the chunk option `include=FALSE`. In this setup
chunk we set the default value for the option `echo` to `FALSE`, meaning that
code is hidden by default.
Also check out the header, in which we explicitly set `title`, `date`, and
`author` - the result of this can be seen in the rendered document. To comply
with the respective tasks we added the specifications
`toc: true` and `toc_float: true` to the `html_document` to add the
floating table of contents, and `code_download: true` to add the code
download button.
To the `pdf_document` call we only added `toc: true` to get the table of
## A second level heading
Again some text. Here is the first chunk.
The code is shown in the rendered document because we set the chunk option
`echo=TRUE`, and so is the output produced by the code because the chunk
option `include` is set the `TRUE` by default:
```{r, echo=TRUE}
vector_random_numbers <- rnorm(
n = 12, mean = 5, sd = 2)
## A visualization
Here we produce the desired ggplot (the code for which remains hidden because
we did not deviate from the default value of `echo`, which we set to `FALSE`
in the setup chunk.)
# Using Netlify Drop
The document was published using [Netlify Drop](,
as explained in the slides.
This is the reason the file is called `index.Rmd`: Netlify Drop only works if
a `html`-file called `index.html` is included in the uploaded directory.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment