5 questions about flights dataset

# 1.Which Airlines most dep_delay ?
flights %>%
     select(carrier,dep_delay)%>%
     arrange(dep_delay)%>%
     left_join(airlines,by = "carrier")%>%
     head(5)
  

# 2. Which Airlines most arr_delay ?
flights %>%
     select(carrier,arr_delay)%>%
     arrange(arr_delay)%>%
     left_join(airlines,by = "carrier")%>%
     head(5)

# 3. which airline is the most airtime in 2013 ?
flights %>%
     select(carrier,air_time)%>%
     arrange(-air_time)%>%
     left_join(airlines,by = "carrier")
  

# 4. which airline is the most flight in 2013 ?
flights %>%
  count(carrier) %>%
  arrange(-n)
            
# 5. which month is the most flight in 2013 ?
flights %>%
  group_by(month)%>%
  summarise(n=n())%>%
  arrange(-n)

Pizza restaurant database

library(RPostgreSQL)
library(tidyverse)

con <- dbConnect(PostgreSQL(),
                 host = "arjuna.db.elephantsql.com",
                 port = 5432,
                 user = "ztghfmjr",
                 password = "E3ksV-1P8PUm7Q0YzBFZbXQYxTWhsSk1",
                 dbname = "ztghfmjr")

menu_id <- 1:9
menu <- c("Hawiian","Super bacon","Ham and cheese","Meat lover","Chicken supreme",
          "BBQ paradise","Seafood mania","Chrimp cooktail","Extreme cheese")
menu_price <- c(99,99,99,129,129,129,279,279,279)
pizza_menu <- data.frame(menu_id,
                  menu,
                  menu_price)

dbWriteTable(con,"pizza_menu",pizza_menu)

size_id <- c("s","m","l")                 
size_price <- c(0, 100, 200 )
pizza_size <- data.frame(size_id,size_price)
dbWriteTable(con,"pizza_size",pizza_size)

customer_name <- c("toy","jay","lisa")
customer_id <- c(1,2,3)
customers <- data.frame(customer_name,customer_id)
dbWriteTable(con,"customers",customers)

dbDisconnect(con)