swirl v2.4.5


Monthly downloads



Learn R, in R

Use the R console as an interactive learning environment. Users receive immediate feedback as they are guided through self-paced lessons in data science and R programming.



Build Status CRAN version Downloads


swirl is a platform for learning (and teaching) statistics and R simultaneously and interactively. It presents a choice of course lessons and interactively tutors a student through them. A student may be asked to watch a video, to answer a multiple-choice or fill-in-the-blanks question, or to enter a command in the R console precisely as if he or she were using R in practice. Emphasis is on the last, interacting with the R console. User responses are tested for correctness and hints are given if appropriate. Progress is automatically saved so that a user may quit at any time and later resume without losing work.

swirl leans heavily on exercising a student's use of the R console. A callback mechanism, suggested and first demonstrated for the purpose by Hadley Wickham, is used to capture student input and to provide immediate feedback relevant to the course material at hand.

swirlify is a separate R package that provides a comprehensive toolbox for swirl instructors. Content is authored in YAML using the handy tools described on the instructors page of our website.

The program is initiated with swirl(). Functions which control swirl's behavior include bye() to quit, skip() to skip a question, main() to return to the main menu, play() to allow experimentation in the R console without interference from swirl, nxt() to resume interacting with swirl, and info() to display a help menu.

Installing swirl (from CRAN)

The easiest way to install and run swirl is by typing the following from the R console:


As we continue adding new features and content, we will make new versions available on CRAN as appropriate (every 1-2 months, most likely).

Installing the latest development version (from GitHub)

To access the most recent features and content, you can install and run the development version of swirl using the devtools package:

devtools::install_github("swirldev/swirl", ref = "dev")

Contributing to swirl's development

If you'd like to get involved, please fork this repository and submit a pull request with your proposed changes. We're happy to chat if you have any questions about the source code.

Using swirl in the classroom

Instructors around the world are using swirl in their classrooms. We think this is awesome. If you're an instructor, please feel free to do the same -- free of charge. While your students may be paying to take your course or attend your institution, we simply ask that you don't charge people directly for the use of our software or instructional content.

If you are not sure about a particular use case, don't hesitate to send us an email at info@swirlstats.com.

Functions in swirl

Name Description
install_course_github Install a course from a GitHub repository
rmatch_calls Recursively expand match calls in an expression from the bottom up.
uninstall_all_courses Uninstall all courses
install_course_google_drive Install a course from a zipped course directory shared on Google Drive
uninstall_course Uninstall a course
install_from_swirl Install a course from the official course repository
select_language Select a language
is_robust_match Recursively expand both the correct expression and the user's expression and test for a match. CAUTION: May raise errors, as in rmatch_calls.
install_course_zip Install a course from a zipped course folder
install_course_url Install a course from a url that points to a zip file
expr_creates_var Test that a new variable has been created.
expr_uses_func Test that a particular function has been used.
func_of_newvar_equals Test the result of a computation applied to a specific (user-named) variable created in a previous question.
main Return to swirl's main menu.
install_course_dropbox Install a course from a zipped course directory shared on Dropbox
play Tell swirl to ignore console input for a while.
install_course_directory Install a course from a course directory
omnitest Test for a correct expression, a correct value, or both.
nxt Begin the upcoming question or unit of instruction.
swirl_options Get swirl options
info Display a list of special commands.
swirl An interactive learning environment for R and statistics.
reset Start over on the current script question.
install_course Install a course from The swirl Course Network or install a course from a local .swc file.
restart Restart the current swirl lesson.
var_is_a Test that the value of the expression is of a specific class.
zip_course Zip a course directory
val_matches Test that the user's expression matches a regular expression.
skip Skip the current unit of instruction.
val_has_length Test that the value of the expression has a particular length.
submit Submit the active R script in response to a question.
email_admin Send diagnostic email to swirl admin
any_of_exprs Test that the user has entered one of several possible expressions.
AnswerTests Answer Tests
expr_identical_to Test that the user has entered a particular expression.
expr_is_a Test that the expression itself is of a specific class.
bye Exit swirl.
calculates_same_value Test that the user's expression evaluates to a certain value.
InstallCourses Installing Courses
delete_progress Delete a user's progress
No Results!

Last month downloads


URL http://swirlstats.com
License MIT + file LICENSE
Encoding UTF-8
LazyData true
RoxygenNote 7.0.2
NeedsCompilation no
Packaged 2020-01-16 02:44:30 UTC; sean
Repository CRAN
Date/Publication 2020-01-16 15:20:02 UTC

Include our badge in your README