Unit 2: Working with Data

In this unit you will learn more about matrices, dataframes,and lists, and how to import, export, and manage data.

Follow the links to each lecture, lab, and reading.

Scroll down to download the SWIRL lessons.

Data for the labs for this unit can be found here

Lesson 1. How to work with dataframes and matrices

Lecture: Details of dataframes and matrices.

Learning Goals:

SWIRL:

Lab: Unit 2: Lab 1

Reading: Missing Data

Functions: matrix(), data.frame(), rbind(), cbind(), head(),tail(), str(), is.foo(), nrow(), ncol(), dim(), rowSums(), colSums(), t().

Lesson 2. How to extract subsets of data

Lecture: Subsetting and indexing in R

Learning Goals:

SWIRL: Indexing and subsetting

Lab: Unit 2: Lab 2

Reading: Healy, K. 2018. The Plain Person’s Guide to Plain Text Social Science Link. Chapter 1. Introduction. (more if you want!)

Functions: order(), subset(), [, [[, $

Lesson 3. How to get data into and out of R

Lectures:

Learning Goals:

SWIRL: Importing data

Lab: Unit 2: Lab 3

Best Practice: Managing Data

Functions: read.table(), read.csv(), write.table()

Lesson 4. How to work with and access lists

Lecture: Understanding and accessing lists

Learning Goals:

SWIRL: Lists

Lab: Unit 2: Recap

Functions: list()