You’re an instructor!

swirl is a platform for teaching R programming and data science. However, an educational platform is only as good as the content it delivers to students. Although we have contributed some content ourselves, swirl is designed in such a way that you can create your own interactive content and share it freely with students in your classroom or around the world.

The swirlify R package provides a comprehensive toolbox for swirl instructors. Our authoring tools will guide you effortlessly through the process of creating interactive content, so that you can focus on the message you want to convey to students. The instructions that follow will have you writing your own interactive content with swirlify in just minutes! For more complete instructions about writing swirl courses please see the swirlify documentation.

Step 1: Get R

In order to run swirl and swirlify, you must have R 3.1.0 or later installed on your computer. If you are on a Linux operating system, please visit our Installing swirl on Linux page.

If you need to install R, you can do so here.

For help installing R, check out one of the following videos (courtesy of Roger Peng at Johns Hopkins Biostatistics):

In addition to R, it’s highly recommended that you install RStudio, which will make your experience with R much more enjoyable.

If you need to install RStudio, you can do so here. Select the appropriate installer for your operating system.

Step 3: Install swirl and swirlify

Open RStudio (or just plain R if you don’t have RStudio) and copy and paste the following commands into the console to install everything you need:

install.packages(c("swirl", "swirlify"))

Step 4: Start swirlify

Type library(swirlify) at the R prompt to load the package. You’ll have to repeat this step every time you restart R or RStudio.

Step 5: Create a new lesson or edit an existing one

swirl courses are collections of individual lessons. It’s up to you how long you’d like each lesson to be, but we think it’s better to have many short, focused lessons than a few long, very general ones.

To create a new lesson:

new_lesson("My Lesson", "My Course")

This will create a course directory in your current working directory that looks like this (notice the underscores):

─ My_Course
  └─ My_Lesson
     ├─ lesson.yaml
     ├─ initLesson.R
     ├─ dependson.txt
     └─ customTests.R

To start working on an existing lesson:

set_lesson() # Set the lesson interactively

## OR...

set_lesson("path/to/My_Course/My_Lesson/lesson.yaml") # Set the lesson directly

Regardless of whether you use new_lesson() to create a new lesson or set_lesson() to open an existing one, swirlify should open the lesson file automatically for you to start editing.

Step 6: Create your interactive content!

For more complete information see the swirlify documentation, but here some helpful hints to get you on your way:

- Class: text
  Output: "The following command assigns the mean of x to y: y <- mean(x)."

Step 7: Ask questions and get involved

To ask and answer questions about authoring swirl content, check out our swirl discussion group.