Shiny without Shiny: RTutor in RStudio’s new Visual Markdown Mode

[This article was first published on Economics and R - R posts, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

RStudio version 1.4 brought many great enhancements. My favorite feature is the new visual markdown editing mode. This allows to solve interactive RTutor problem sets with a shiny look directly in the RStudio editor. Here is a screenshot:

The example RTutor problem set VisualMode.Rmd is shown in the left pane. It is opened in the visual markdown editing mode. Students can edit its code chunks as in any other RMarkdown document in RStudio. The RTutor package adds RStudio addins that allow to check the problem set and get hints. For this to work a “compiled” version of the sample solution (here VisualMode.rps) must be in the same folder as the Rmd file. In the screenshot above, the student makes a common beginner’s mistake to add the error term u in the call to lm. Asking for a hint yields the automatic adaptive hint shown in the console, which should hopefully guide the student to the correct solution.

While the problem set can also be solved in the traditional source editor mode, the visual mode looks much nicer because

  • latex formulas
  • images
  • web links

are all directly shown in a nicely rendered version. So these problem sets look almost as nice as the web-based shiny versions of RTutor (e.g. here) or learnr exercises, which are also completely shiny based.

The advantage of directly using RStudio is that students can work in the IDE that they use later for work with all its great features like the Environment pane and the R console. Several of my students said that they preferred the RStudio environment even if the problem sets don’t look as nice. With the visual markdown mode, directly using RStudio should be even more attractive since a lot of the visual gap to shiny based problem sets can be mended.

While typically all RTutor problem sets look nicer in the visual markdown mode, I have not yet especially optimized the RTutor problem sets of my courses Empirical Economics with R and Market Analysis with Econometrics and Machine Learning to the visual markdown mode. But I will probably do so sooner or later. An example solution file that exploits the visual markdown features (formulas, images, links) is here.

Note: You should edit the solution file only in source editing mode, since the visual markdown mode automatically rewrites files in a way that is incompatible with some RTutor syntax that extends RMarkdown to specify blocks like awards or custom hints. Luckily there is no problem for the resulting Rmd file given to students. It should generally work without problems in visual markdown mode.

LeverageData’s RTutor fork for more shiny Shiny.

There are some features that can still be better implemented with the shiny-based version of RTutor problem sets, mainly multiple choice quizzes or customized HTML. In this context, I am happy to report that RTutor now has another active fork by LeverageData. LeverageData is a young data science consulting firm that also offers professional data science courses that specialize on German speaking participants. (Disclaimer: The Co-founder and CEO Martin Kies was my PhD student, so I root a bit for them, but except for some joint advancement of RTutor, I am not involved with the firm.)

LeverageData uses shiny-based RTutor problem sets for their courses and they have included some nice new features into RTutor. In particular, multiple choice quizzes can be more adaptive in their fork and e.g. contain images. This shiny app showcases the new quiz features. While I already merged some elements from LeverageData’s fork into the main RTutor fork, the forks will probably remain a bit varied since some of their pure shiny features are less compatible with RMarkdown based problem sets.

To leave a comment for the author, please follow the link and comment on their blog: Economics and R - R posts. offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)