rstudio / learnr

Interactive Tutorials with R Markdown
https://pkgs.rstudio.com/learnr
Apache License 2.0
710 stars 239 forks source link

feat(exercise): Support `exercise.pipe` option #804

Closed gadenbuie closed 1 year ago

gadenbuie commented 1 year ago

Globally choose pipe characters, or set them per exercise. Default is chosen based on the current version of R in the rendering environment.

Supersedes #786


You can set the characters used for the pipe shortcut at the tutorial level with

knitr::opts_chunk$set(exercise.pipe = "%>%")

Or you can set the pipe option at the individual level using the exercise.pipe chunk option.

```{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. 
statik commented 1 year ago

@gadenbuie thank you for this!