Skip to content

Instantly share code, notes, and snippets.

@graebnerc
Created April 6, 2022 12:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save graebnerc/a10d086e45f624882ed1b52563569fb2 to your computer and use it in GitHub Desktop.
Save graebnerc/a10d086e45f624882ed1b52563569fb2 to your computer and use it in GitHub Desktop.
A possible solution to the R-Markdown exercise
---
title: "A possible solution"
author: "Claudius"
date: "4/6/2022"
output:
html_document:
toc: yes
toc_float: yes
code_download: yes
theme: "spacelab"
pdf_document:
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
contents.
## 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)
vector_random_numbers
```
## 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](https://app.netlify.com/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