Chapter 2

CSVs

Quiz 1

Excel

Quiz 2

Column names

What if you import in a spreadsheet with a space in the column name like below?

How do you refer to the the First name variable/column with $ and not the []?

# Add to the line below 

burgers$
burgers$`First name`

Clean up column name

Let’s create a new data frame burgers2 from burgers because we’re going to change it up.

Run the command on the First name variable/column to strip out the spaces and characters and replace them with periods.

# Modify the line of code below

burgers2 <- burgers

colnames(burgers2) <- _______(colnames(burgers2))

burgers2
burgers2 <- burgers

colnames(burgers2) <- make.names(colnames(burgers2))

burgers2

Rename a column

Use the special dplyr function to rename the id variable in burgers to employee_id

# Modify the line of code below

burgers2 <- 
  
burgers2
burgers2 <- rename(burgers, employee_id=id)

burgers2

Filter out NAs

Create a new data frame called kids by filtering out the NAs from grade column in burgers.

# Modify the line of code below 

kids <- _______(burgers2, !____(______))

kids
kids <- filter(burgers2, !is.na(grade))

kids