make_exercise | R Documentation |
When writing tutorials, it is handy to be able to insert the
skeleton for a new code exercise or question. We bind make_exercise()
and
friends as an RStudio add-in to provide this functionality. Note that the
function determines the correct exercise number to use and also adds
appropriate code chunk names, based on the exercise number and section
title.
make_exercise(type = "code", file_path = NULL)
make_no_answer()
make_yes_answer()
type |
Character of question type. Must be one of "code", "no-answer", or "yes-answer". |
file_path |
Character path to a file. If NULL, the RStudio active document is used, which is the default behavior. An actual file path is used for testing. |
It appears that the RStudio addins must have function names only as
the Binding value. In other words, you can't have make_exercise(type = 'no-answer')
as the value. So, we need two extra functions —
make_no_answer()
and make_yes_answer()
—which just call
make_exercise()
while passing in the correct argument.
Exercise skeleton corresponding to the type
argument.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.