announce: Adds comments to the output of code in a learnr block.

Description Usage Arguments Details

View source: R/code_comments.R

Description

Often the scaffolding put in a {learnr} exercise chunk consists of more than one command that produces output. By default, {learnr} will print the outputs one after the other. This can make it hard for the reader to determine which line of code produced which output. announce() can insert comments into the output.

Usage

1

Arguments

code

the code that you want to display

comment

A character string to print as a comment

Details

Use announce() in either of two ways:

  1. As a simple function call, e.g. announce("my message") which will display "my message" as a comment at the corresponding point in the exercise chunk output.

  2. As the receiver of a piped-in command, e.g. sqrt(2 + 3) %>% announce("my message"). This will print out the code on the LHS of the pipe, along with the message as a comment.


dtkaplan/etude documentation built on Oct. 19, 2020, 7:56 p.m.