library(tidyverse)
output_function <- function(var1,var2){
iris |> filter(Species == !!(var1)) |>
mutate(v2=!!sym(var2) * 2 )
}
#output_function("setosa","Petal.Length")
#output_function("virginica","Petal.Width")
# a data.frame of what to do ...
(to_do_tbl <- tibble(filt=c("setosa","virginica"),
mult=c("Petal.Length","Petal.Width")) |> mutate(label=paste0(filt,"_",mult)))
results <- map2(to_do_tbl$filt,
to_do_tbl$mult,
output_function) |> set_names(to_do_tbl$label)
#its a list of data.frames
str(results,max.level = 1)
#accessing by number or by name ; glimpse to not get flooded by too much info
glimpse(results[[1]])
glimpse(results[["virginica_Petal.Width"]])