# Unit 1: Getting StaRted

In this unit, you will become familiar with the R console, RStudio, and basic actions and operations in R.

## Lesson 1. What is R?

Lecture: Overview of R, demonstration of R.

Learning Goals:

• Understand what R can and cannot do,
• Install R and RStudio,
• Know how to navigate within RStudio.

Lab: Unit 1: Lab 1

 Reading: NYT article, 2009 Quartz article, 2019

Functions: None.

## Lesson 2. How to use R as a calculator

Lectures:

Learning Goals:

• Perform operations on numbers and integers,
• Assign numeric and character data to variables,
• Manipulate variables with operators,
• Understand and use paths and working directories.

SWIRL: Basic building blocks

Lab: Unit 1: Lab 2

Functions: `<-`, `getwd()`, `setwd()`.

## Lesson 3. How to work with vectors

Learning Goals:

• Generate vectors using `c()`, `:`, `seq()`, `rep()`,
• Assign these vectors to variables and manipulate them,
• Identify types of vectors (numeric, integer, factor, character, …)
• Plot individual vectors with `plot()`.

SWIRL:

Best Practice: Code style guide

Labs:

Functions: `c()`, `:`, `seq()`, `rep()`, `plot()`, `is.vector()`, etc

## Lesson 4. How to summarise vectors

Lecture: Using functions

Learning Goals:

• Navigate to and from working directory with `getwd()` and `setwd()`,
• Subset vectors with logical statements (`>`, `<`, `!=`, `==`),
• Use functions to perform calculations, with `sum()`, `mean()`, `sd()`, etc.
• Summarise the distribution of a vector with `boxplot()` and `hist()`.

SWIRL:

Lab: Unit 1: Recap

Functions: `getwd()`, `setwd()`, `sum()`, `mean()`, `sd()`, `summary()`, `length()`, `boxplot()`, `hist()`

# SWIRL

The lessons we will use are available online and you need to download them to your laptop.

1. Open RStudio

2. In the console panel, next to the arrow (>), copy and paste the following:

``````library(swirl)
install_course_github("intro2r", "swirl_courses", multi = TRUE)
``````

``````swirl()