Example Document

tutorial::go_interactive()

You can use the tutorial package to convert static code chunks into 'fiddles', i.e. editors where people can experiment with your code. If you specify the ex and type properties, tutorial knows what to do:

a <- 2
b <- 3

a + b

You can also create interactive exercises right inside your R Markdown document. Suppose you want to explain people how variable assignment works in R. Create an exercise with a certain identifier, create_a in this case. Then, in different R code chunks, specify the elements of the exercise by setting the type inside the code chunk options.

b <- 5
# Create a variable a, equal to 5


# Print out a
# Create a variable a, equal to 5
a <- 5

# Print out a
a
test_object("a")
test_output_contains("a", incorrect_msg = "Make sure to print `a`.")
success_msg("Great!")


Try the tutorial package in your browser

Any scripts or data that you put into this service are public.

tutorial documentation built on May 2, 2019, 9:34 a.m.