September 9, 2020

Combining Multiple Tables

Today we will discuss the a few more ideas from Chapter 4 and go over some of the current homework. In particular how to deal with dates to weeks.

The dataset we are looking at in the homework is the nycflights13 dataset.

Tables:

flights
airlines
planes
airports

Review

pipeline using the pipe %>%

On page 73 there is a nice way to think about this.

df %>% f(y)

means

f(df,y)

Review

keys

On page 79 there is a reference to keys in relational database management systems.

keys are what are used to merge two data tables together.

primary key and foreign key

The primary key is in the first table and foreign key is in the second table.

Review

paste() and paste0()

These functions can be used to combine strings together.

With the 0 there is no space added.

Good news. There is a newer package that does the same thing but a bit nicer. See the glue package and the function glue().

Homework

In the homework a variable needs to be created to give weeks of the year? How do we do this? Do a google search.

Combining Three Date Variables in R

How to get week numbers from dates?