Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
Lesson Template
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
prace-lessons
Lesson Template
Commits
76de8a2b
Commit
76de8a2b
authored
10 years ago
by
John Blischak
Browse files
Options
Downloads
Patches
Plain Diff
Add documentation for writing lessons in R Markdown. Fixes #149.
parent
8e8d1a81
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
LAYOUT.md
+75
-0
75 additions, 0 deletions
LAYOUT.md
with
75 additions
and
0 deletions
LAYOUT.md
+
75
−
0
View file @
76de8a2b
...
...
@@ -259,6 +259,81 @@ Each topic page must be structured as follows:
some code
~~~
## Writing Lessons with R Markdown
Lessons can be written in R Markdown and converted to Markdown. The
main advantages of maintaining lessons in an executable format is 1)
not having to copy-paste the output and 2) it is easier to test if
new changes break code in other parts of the lesson. The main
disadvantage is that there will be more noise when merging the
generated content (e.g. different R versions have slightly different
wording of error messages).
After writing or editing a lesson written in R Markdown, automatically
generate the Markdown and html versions by running the command
`make
preview`
. This first runs the
`knit`
command from the
[
knitr
][]
package to convert to Markdown, and then pandoc to convert to html.
[
knitr
]:
http://yihui.name/knitr/
To ensure that the generated Markdown files follow the lesson template
guidelines,
`source`
the R file
[
tools/chunk-options.R
](
tools/chunk-options.R
)
. This file contains
settings that format the input and output code chunks, send all
generated figures to
`fig/`
instead of
`figure/`
, and specify a few
other knitr options. Thus a lesson should look like the following:
---
layout: page
title: Lesson Title
subtitle: Topic Title
minutes: 10
---
```{r, include=FALSE}
source("tools/chunk-options.R")
opts_chunk$set(fig.path = "fig/topic-title-")
```
> ## Learning Objectives {.objectives}
>
> * Learning objective 1
> * Learning objective 2
Paragraphs of text
--- possibly including [definitions](reference.html#definitions) ---
mixed with:
```{r chunk-name}
# code to be exectued
```
More text.
When using
[
tools/chunk-options.R
](
tools/chunk-options.R
)
, figures are
automatically sent to
`fig/`
. However it is easier to manage all the
figures in a lesson if their names are more descriptive. This can be
acheived by setting a more informative
`fig.path`
like the example
above, which will prepend "topic-title-" to all generated figure
names. Furthermore, it is recommended to name the code chunks. Thus if
a plot was generated in the example code chunk above, it would be
saved as
`fig/topic-title-chunk-name.png`
.
To avoid unecessary merge conflicts in the generated content, do not
randomly generate data. Instead use
`set.seed`
so that any randomly
generated data is always consistent. If introducing the concept of
random number generation is outside the scope of the lesson,
`set.seed`
can be hidden from the learners in a separate code chunk.
```{r set-seed, echo=FALSE}
set.seed(12345)
```
```{r normal-distribution}
ex_dat <- rnorm(100)
summary(ex_dat)
```
## Motivational Slides
Every lesson must include a short slide deck suitable for a short
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment