Trouble using group_by and map2 together

thanks.
I first lifted out the hardcoded model variable targer name

df %>%
  group_by(edge) %>%
  anova_test(as.formula(paste0("nl","~ trt")), error = model, type = 3)

this worked fine. Then making the params explicit and to my taste clearer to follow, as map wants a sequence to iterate over and a function to apply at each iteration i like to make the function call part obvious


  anova_test(data=group_by(df,edge),
             formula = as.formula(paste0("nl","~ trt")),
             error = model,
             type = 3)
  

then we can map, we use the names of the models_1 list


  map(names(models_1) ,
      ~ anova_test(data=group_by(df,edge),
                   formula = as.formula(paste0(.x,"~ trt")),
                   error = models_1[[.x]],
                   type = 3))
1 Like