swirl is a software package for the R programming language that turns the R console into an interactive learning environment. Users receive immediate feedback as they are guided through self-paced lessons in data science and R programming.
I think I first came across swirl in mid-2014, while working through the early stages of the Data Science Specialization on Coursera, put together by Johns Hopkins University professors Roger Peng, Brian Caffo and Jeff Leek.
The courses in this specialization make extensive use of swirl to introduce and explore various topics in the form of interactive programming assignments in R (e.g. R programming). This is probably largely due to the fact that these three professors were involved in the early development of swirl with it’s creator Nick Carchedi who is a graduate of Johns Hopkins Biostatistics. For those who may be new to R or data science - these Coursera courses are an excellent resource which I can highly recommend.
Of course there are many, many great resources for getting started (and later improving) with R programming: try the online learning suggestions from RStudio, or take a look through some of these Quora answers and you will find a wealth of R resources: online courses, books, tutorials and more. If that’s not enough for you - Google is your friend. There is so much out there!
I’d like to focus on swirl in this post however, since I feel it doesn’t really get as much attention as it should. There are three key ways in which I think swirl has got it right as a learning platform:
- it directly facilitates learning by doing
- it runs from within R
- it is free and open source
Learn by Doing
First is the “learn by doing” component, which is almost as crucial to learning to program as it is to learning to ride a bike, or to drive a car.
Sure, programming is mostly cognitive, but in my experience you only begin to internalize and understand concepts, syntax etc properly when you start to apply them. The primary learning you do when learning to ride a bike or drive a car happens when getting onto a bike or into a car for the first time and (usually) having someone walk you through the interface, controls etc as you experience them for yourself.
The need to learn by doing might seem obvious, but if you stop and think about it for a moment, you might find that given the wealth of great R programming books, videos, courses etc its entirely plausible that you could begin your learning path there and after being pulled in different directions end up spending very little (or no) time in R. A few days ago I was chatting to one of my cousins who has been learning R on and off for a while now and when I asked him how it was going he said he thinks his learning process so far has lacked sufficient “hands on” practice with R.
swirl is great because it forces you to learn by doing, whether that means copying code/syntax from an instruction, interrogating R’s help documentation in order to work out how to make use of a particular function, or experimenting with different options by trial and error.
Learn R, in R
Second is the “learn R, in R” component, which is what makes swirl pretty unique. There are a few other learning platforms which embed or reproduce the R console within their own web environments to produce a similar outcome, but at the end of the day, in some or other (possibly quite small) respects none can be equivalent to the reality of working in a local R environment on your own computer, whether that be RStudio (recommended!), some other IDE of your choosing, or even just running R from the terminal.
Since swirl runs within R itself, when you learn with swirl, you can work with the exact same local R environment you will later use to program in R. By way of a poor analogy, this is somewhat like the difference between taking your driving lessons in someone elses car and taking them in the car that you plan to use once you have obtained your license. If you have the option of the latter, there are certainly benefits to doing so.
At the same time I do acknowledge that there can also be some downsides to this when considered from certain perspectives (e.g. the swirl approach of embedding the learning environment within R is not as flexible as the reverse and does constrain the learning environment to some extent). However as mentioned above I think what swirl has to offer is unique in this respect and it is worth highlighting that the advantages are significant.
I am certainly not averse to other R learning platforms and realize that some have other advantages over swirl. For example, it is worth noting that the creator of swirl is now working at DataCamp, which is an excellent learning platform that offers a host of courses in both Python and R, some of which in fact still make use of swirl.
Free and Open Source
Third is the fact that swirl is completely free and open source. This means that students, instructors and other R developers can dig into both swirl itself and swirl lesson content, learn from it, and then suggest and/or contribute towards corrections and improvements over time. Being able to look behind the curtain opens up a world of learning opportunities.
For example, my first ever pull request on GitHub, was in the swirl courses repository. It was a only simple spelling correction for lesson content from one of the aforementioned Coursera swirl courses, but you’ve got to start somewhere. It’s open source projects like swirl that offer these opportunities for “getting started”.
In a little over two years since that first pull request, and I have been able to contribute in a number of different ways to various swirl projects and courses, learning as I go. A few months ago, I also decided to get started on two of my own swirl courses, which I’m continuing to work on iteratively as and when I can make time. I’ve still got a long way to go, but I’ve already learnt so much through the process, and will definitely discuss these further in later posts.
My recommendation is that you checkout swirl if you haven’t already done so, because it is worth using. The easiest starting point is the students page on the swirl website, which provides all the steps you’ll need (especially if you are completely new to R).
And if you’re a more advanced R user, why not consider contributing a course? The documentation for swirl is excellent, and it is very easy to get started creating a course. All the information you’ll need to do so is provided on the instructors page on the swirl website. Also note that the developers of swirl have created a swirl course network (SCN) in an effort to “list and organize all publicly available swirl courses”. If you have created a swirl course or are considering doing so, please take a look at this to find out how to share your course.
If you need help or would like to collaborate on a swirl course please get in touch with me. I’ll be happy to assist where and when I am able to do so.