Swirl Package in R

Francis Mensah showed us how to use the Swirl package to interactively learn R

R
Swirl package
workshop
self-learn
Author

Simisani Ndaba

Published

July 22, 2023

Meetup Description

Francis Mensah explored the features and benefits of the Swirl package and its significance for R users with a live demonstration.

About the speaker


Francis is the Founder and Research Scientist at Ghana R Users Community. He is a Statistician, programmer and Data Analyst with a strong background and experience in Project Management, monitoring and evaluation (M&E) and Research. A Co-founder of KIMS International Managing Partner with Research Consulting and Services, a firm that provide M&E, Research and capacity building in the areas of education, public health, gender, water and sanitation and livelihood for governmental and none-governmental institutions.

Contact Francis @


Francis Mensah on Twitter at https://twitter.com/MensahMf26 + https://twitter.com/RUsersGhana

Swirl Package

The Swirl package in R is a valuable tool for enhancing the learning experience of R users. It provides an interactive and hands-on approach to mastering R programming through a series of interactive lessons and exercises. The Swirl package serves as a self-paced learning platform that offers a wide range of interactive courses covering various topics in R programming. These courses are designed to guide users through step-by-step lessons, allowing them to practice coding directly within the R environment. Swirl provides immediate feedback, quizzes, and challenges, fostering an engaging and immersive learning experience.

Install and run a course automatically from swirl


This is the preferred method of installing courses. It automates the process by allowing you to do everything right from the R console. The following is a demonstration from installing the Swirl package. The comments are the outcomes of the line code.

Tip

Scroll the bottom bar of the block to the right to see the full statements and comments.

  1. Make sure you have a recent version version of swirl:
install.package("swirl")
  1. Load the package and type “swirl()” when you are ready.
library("swirl")
"| Hi! Type swirl() when you are ready to begin."
swirl()
  1. The prompt will ask what to call you during your session. You can type your name or your username.
"| Welcome to swirl! Please sign in. If you've been here before, use the same name as you did then. If you | are new, call yourself something unique."

What shall I call you? | "Simi"
  1. The prompt will show you a list of modules to choose from. From selecting from either 0 to 5, the course selection will generate the course you want to practice.
"| To begin, you must install a course. I can install a course for you from the internet, or I can send you 
| to a web page (https://github.com/swirldev/swirl_courses) which will provide course options and directions
| for installing courses yourself. (If you are not connected to the internet, type 0 to exit.)"

1: R Programming: The basics of programming in R
2: Regression Models: The basics of regression modeling in R
3: Statistical Inference: The basics of statistical inference in R
4: Exploratory Data Analysis: The basics of exploring data in R
5: Don't install anything for me. I'll do it myself.

"Selection: 1
  |===================================================================================================| 100%

| Course installed successfully!


| Please choose a course, or type 0 to exit swirl."

1: R Programming
2: Take me to the swirl course repository!

"Selection: "

"| Please choose a lesson, or type 0 to return to course menu.

 1: Basic Building Blocks      2: Workspace and Files        3: Sequences of Numbers    
 4: Vectors                    5: Missing Values             6: Subsetting Vectors      
 7: Matrices and Data Frames   8: Logic                      9: Functions               
10: lapply and sapply         11: vapply and tapply         12: Looking at Data         
13: Simulation                14: Dates and Times           15: Base Graphics"           

Selection: 1
  1. Your selection will take you into the lesson with the percentage at the far right showing your progress within the lesson.

  |                                                                                                   |   0%

| In this lesson, we will explore some basic building blocks of the R programming language.

...

  |===                                                                                                |   3%
| If at any point you'd like more information on a particular topic related to R, you can type help.start()
| at the prompt, which will open a menu of resources (either within RStudio or your default web browser,
| depending on your setup). Alternatively, a simple web search often yields the answer you're looking for.

...

  |=====                                                                                              |   5%
| In its simplest form, R can be used as an interactive calculator. Type 5 + 7 and press Enter.

Resources

You can learn and do more with the following Swirl material with tutorials and explanation of Swirl courses.

Swirl official site

Swirl Github repository

Swirl Github course explanation