Skip to main content Link Menu Expand (external link) Document Search Copy Copied

Jan 27. Using R

Worked Example

Today we will begin using R! R is a powerful tool for data analysis.

Before class

You should follow the instructions in R4DS 1.4 to

  1. Install R, which is statistical software
  2. Install RStudio, which is a particular environment we will use to work with R
  3. Install the tidyverse package as described in R4DS 1.4.3

If you have trouble, post a question in Ed or ask in office hours. If something goes wrong with your computer so that you aren’t fully set up it’ll be ok—for this class session we’ll just begin to get familiar with the R environment.

During class

We will work with median_income.csv, which contains the median U.S. household income from 1968 to 2022, adjusted for inflation to 2022 dollars.

You can load this into R by first loading tidyverse and then loading the data.

library(tidyverse)
median_income <- read_csv("https://info3370.github.io/sp23/assets/data/median_income.csv")

In class, we will explore these data and visualize the trend in median U.S. household incomes.

After class

You may want to read the other parts of R4DS 1 which provide an overview of the approach to data science taken by this textbook.

Summary video: What we covered today