A New Week!



We aren’t computer scientists and that’s okay!

We make lots of mistakes. Mistakes are funny. You can laugh with us.

Let’s go, Simba, Pumbaa, and Timon!





1 More data type: date-time




It’s about time! Lubridate makes working with dates much easier.

We can find how much time has elapsed, add or subtract days, and find seasonal and day of a week averages.









1.1 Load the lubridate package

2 Join tables



2.1 left_join


left_join(scrap, convert, by = c(“columns to join by”))


left_join() works like a zipper to combine 2 tables based on one or more variables. It’s called “left”-join because the entire table on the left side is retained.

Anything that matches from the right table gets to join the party, but any rows that don’t have a matching ID will be ignored.


Remember our porg friends? We haven’t share their names.

The joined result:

2.2 Other joins

right_join(): includes all rows in right table.

inner_join(): includes all rows in both tables.

full_join(): includes all rows in left or right table.

Exercise

Install and load the nycflights13 package.

Create a table that includes all flights and weather of their destination airports.

3 Recap



  • date-time

  • join tables