Dataset for questions 2-4
library(readr)
On_Time_Performance <- read_csv("On_Time_Performance.csv")
## New names:
## • `` -> `...110`
## Warning: One or more parsing issues, call `problems()` on your data frame for details,
## e.g.:
## dat <- vroom(...)
## problems(dat)
## Rows: 570131 Columns: 110
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (28): UniqueCarrier, Carrier, TailNum, Origin, OriginCityName, OriginSt...
## dbl (54): Year, Quarter, Month, DayofMonth, DayOfWeek, AirlineID, FlightNum...
## lgl (27): Div2WheelsOff, Div2TailNum, Div3Airport, Div3AirportID, Div3Airpo...
## date (1): FlightDate
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
Question 3. How many missing values does the column Div2WheelsOff
contain?
data <- read.csv("On_Time_Performance.csv")
sum(is.na(data$Div2WheelsOff))
## [1] 570122
Question 4. What is the average departure delay by carrier? Which
carrier shows the largest departure delay?
library(dplyr)
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
data <- read.csv("On_Time_Performance.csv")
avg_delays <- data %>%
group_by(Carrier) %>%
summarise(Avg_DepDelay = mean(DepDelay, na.rm = TRUE)) %>%
arrange(desc(Avg_DepDelay))
print(avg_delays)
## # A tibble: 18 × 2
## Carrier Avg_DepDelay
## <chr> <dbl>
## 1 B6 20.4
## 2 F9 16.0
## 3 OO 15.1
## 4 OH 13.8
## 5 EV 13.6
## 6 9E 12.4
## 7 G4 10.4
## 8 DL 9.74
## 9 YV 8.86
## 10 MQ 8.82
## 11 WN 8.03
## 12 YX 7.26
## 13 AA 6.93
## 14 UA 5.87
## 15 NK 5.61
## 16 VX 2.83
## 17 HA 1.72
## 18 AS -2.25
largest_delay_carrier <- avg_delays$Carrier[1]
largest_delay_carrier
## [1] "B6"
Question 5. What is the maximum of daily close price for BTC in the
data?
library(jsonlite)
## Warning: package 'jsonlite' was built under R version 4.4.3
url <- "https://min-api.cryptocompare.com/data/v2/histoday?fsym=BTC&tsym=USD&limit=100"
response <- fromJSON(url)
btc_data <- response$Data$Data
max_close_price <- max(btc_data$close, na.rm = TRUE)
print(paste("The maximum daily closing price for BTC in the last 100 days is:", max_close_price))
## [1] "The maximum daily closing price for BTC in the last 100 days is: 106155.61"