I am trying to add a vector of arguments to a nested dataframe, later to be used as addons to the regression formula I will be running with this data. However, I am not able to.. any thoughts?
library(tidyverse)
flights <- nycflights13::flights
flights<- sample_n(flights, 1000)
nested <- flights %>% group_by(origin, dest) %>%
nest() ## groups all the data by the sub series
nested %>% mutate (formula = "airtime ~ distance + carrier")
nested<-nested %>% mutate (add_in = case_when(
origin =="EWR" & dest =="CVG" ~ list("year", "hour"),
origin =="EWR" & dest =="LAX" ~ list("year", "dep_delay")
))
This may have 17-20 different models , with the same basic formula (only addons). is there a cleaner way to do this for 20 models?