I'm trying to create a function that captures the amplitude of flight arrivals and departures. but getting this error: "non-numeric argument to binary operato". even though through the command class I discovered that arr and dep are numeric. I'm using nyclights13 data. Can you guys help?
library("nycflights13")
library("tidyverse")
library("tidylog")
library(magrittr)
library(purrr)
data <- flights %>%
group_by(dep_delay, arr_delay) %>%
summarise(n = n())
deptime_delay <- data$dep_delay
class(data$dep_delay)
arrtime_delay <- data$arr_delay
class(data$arr_delay)
fmp2 <- function(x, y) {
result <- max("deptime_delay:", x, "arrtime_delay:", y) - min("deptime_delay:", x, "arrtime_delay:", y)
return(result)
}
map2(deptime_delay, arrtime_delay , fmp2) %>% head(5)