Week 3: Northeastern’s HPC & Introduction to R - swirl()
July 20, 2021
Overview: Begin learning the basics of coding in R using the program swirl().
Activity | Time | Additional Info |
---|---|---|
Introduction to High Performance Computing | 5 min | Link to slides |
Get started on the HPC | 20 min | Steps to get started with R on the HPC |
Review of coding lingo | 5 min | Link to slides |
Introduction to Swirl() 1: Basic Building Blocks & 3: Sequences of Numbers | 25 min | |
R Challenge 1 | 15 min |
Steps to get started with R on the HPC.
Specific instructions for swirl():
To use swirl(), follow these steps:
1) Type install.packages("swirl")
.
2) Type library(swirl, lib.loc="~/R/x86_64-pc-linux-gnu-library/3.6")
.
3) Type swirl()
.
4) Follow the on-screen instructions. When swirl() asks you to install a course, enter 1
to install “R Programming”.
5) Enter 1
again to choose the “R Programming” course.
6) Enter 1
to choose Lesson 1: Basic Building Blocks.
When you reach the end of the lesson:
1) Enter 1
again to return to the “R Programming” course.
2) Enter 3
to choose Lesson 3: Sequences of Numbers.
To complete the challenge after finishing Lesson 3, enter 0
to exit swirl().
R Challenge #1
-
Assign a value of 7 to a variable called
m
. -
Create a new variable
a
equal to 6 times the value ofm
. -
Find the square root of
a
and store it as another variablen
. -
Create a sequence from 1 to 5 and store is as the variable
g
. -
Create a sequence from 3 to 15 increasing in increments of 3 and store it as the variable
o
. -
Combine all five variables into a vector and store them as a new variable called
mango
. -
Divide
o
byg
and assign the result to the variableb
. -
Use the combine
c()
and repeatrep()
functions to combine the values ofb
,a
, andn
into a vector in the order of the word “banana”, and assign it to a new variable calledbanana
. -
Create a vector called
fruit
that combinesmango
andbanana
. -
Find the length of this new vector
fruit
.