-
Notifications
You must be signed in to change notification settings - Fork 239
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(exercise): Support
exercise.pipe
option (#804)
- Loading branch information
Showing
9 changed files
with
100 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
--- | ||
title: "Exercise Pipe Option" | ||
output: learnr::tutorial | ||
runtime: shiny_prerendered | ||
--- | ||
|
||
```{r setup, include=FALSE} | ||
library(learnr) | ||
library(dplyr) | ||
knitr::opts_chunk$set(echo = FALSE) | ||
``` | ||
|
||
|
||
## Ceci n'est pas une pipe | ||
|
||
Qu'est-ce qu'une pipe, sinon l'idée d'une pipe? | ||
|
||
You can set the characters used for the pipe shortcut at the tutorial level with | ||
|
||
```r | ||
knitr::opts_chunk$set(exercise.pipe = "%>%") | ||
``` | ||
|
||
Or you can set the pipe option at the individual level using the `exercise.pipe` chunk option. | ||
|
||
````{verbatim echo = TRUE} | ||
```{r base-pipe, exercise=TRUE, exercise.pipe="|>"} | ||
mtcars count(cyl) | ||
``` | ||
```` | ||
|
||
By default, if not set otherwise set, learnr will use the base R pipe (`|>`) when the tutorial is rendered in R >= 4.1.0. | ||
|
||
### Old school | ||
|
||
In this next chunk, pressing `Ctrl/Cmd + Shift + M` enters the magrittr pipe: `%>%`. | ||
|
||
```{r magrittr, exercise=TRUE, exercise.pipe="%>%"} | ||
mtcars count(cyl) | ||
``` | ||
|
||
### New school | ||
|
||
In this next chunk, pressing `Ctrl/Cmd + Shift + M` enters the base R pipe: `|>`. | ||
|
||
```{r pipe, exercise=TRUE, exercise.pipe="|>"} | ||
mtcars count(cyl) | ||
``` | ||
|
||
### Night school | ||
|
||
In this next chunk, pressing `Ctrl/Cmd + Shift + M` enters the pipe that matches your R version. It's the base R pipe for R >= 4.1. | ||
|
||
```{r auto, exercise=TRUE} | ||
mtcars count(cyl) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters