The R package 'swirl' allows users to learn R programming by completing interactive lessons within the R console. Lessons (written in the YAML mark-up language) can include educational content such as text, graphics, and links, and multiple choice or open-ended questions. If a user does not answer a question correctly, hints may be provided until the correct answer is given. Although 'swirl' is a valuable package for learning important concepts in R and data science, users are limited in their ability to practice these concepts as 'swirl' lessons are static, so that a user repeating a lesson will see the same questions each time. This motivates an extension to 'swirl' that includes 'template-based problems' that would allow a user to practice on an endless supply of problems for a given topic.
We describe and implement a new package, 'swirl-tbp', that introduces 'template-based practice' problems to the 'swirl' framework. Specifically, 'swirl-tbp' extends 'swirl' by allowing instructors to include template-based problems in 'swirl' lessons. Template-based problems are problems that include numbers, variable names, or other features that are randomly generated at run-time. As a result, a user can be provided with an endless supply of practice problems that differ, e.g., with respect to the numbers used. This allows users to repeatedly practice problems in order to reinforce concepts and practice their problem-solving skills. We demonstrate the utility of 'swirl-tbp' by showing template-based problems for practicing basic R programming concepts such as vector creation and statistical concepts such as the calculation of probabilities involving normally distributed random variables.