---
title: "Exercise_rel_dplyr"
author: "Kathleen Durant"
date: "1/24/2019"
output: pdf_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```

## R Markdown

1. Review the document found at library(datasets) and the data sets for: 
https://cran.r-project.org/web/packages/nycflights13/nycflights13.pdf

```{r }
library(datasets)
library(tidyverse)
library(nycflights13)

```

Identify the New York airports in the airports data frame

```{r }

```
3. Determine the NY airports that fly to one another 
```{r}
```
Determine the flights out of each NY airport 
```{r}
flights %>% select(origin) %>% count(origin)
```
Tracking the flights that are originating from New York airports 

Provide an inner join between the NY destinations airports and the NY airports 

When specifying the by argument the order of the fields matter. dest column is part of the original data frame NY_dest, faa is a column in the NY_airports first_table_col = sec_table_col
Review the columns in the result - what column is not present??
```{r}

```

Why does this generate an error?
```{r}
NY_dest %>% left_join(NY_airports,by=c("faa" = "dest"))
```

Why are there 3 records in this result ? What does the NA represent? 
```{r}
NY_dest %>% right_join(NY_airports,by=c("dest" = "faa"))
```
```{r}
NY_dest %>% left_join(NY_airports,by=c("dest" = "faa"))
# why do we have only 1 record in the result? Is it the same result as the inner join?
```
 why do we have only 1 record in the result? Is this result the same result as the inner join?
 
```{r}
NY_dest %>% full_join(NY_airports,by=c("dest" = "faa"))
```

Is this result the same as  any of the previous results? 


On paper, add another row to the NY_dest data frame. Using the values, 2013, 8, 27, US, 1732, EWR, JFK and compute the mutating JOINS inner_join, left_join, right_join and full_join 