I think I have sorted out a solution that works for my peculiar needs at the moment. The important thing for me was understanding that I can feed a string into !! sym(...) within the function call in order to get the quosure function to work like I was expecting it to.
So then I could create a dataframe with a list of all the permutations I wanted to look at, populate a list of dataframes within that in a loop, and then reduce all those seperate dataframes into one combined frame:
library(tidyverse)
get_max_min <- function(df,feature) {
feature <- enquo(feature)
feature_name <- quo_name(feature)
df %>%
group_by(Species) %>%
summarize(!! paste0("max_", feature_name) := max(!! feature),
!! paste0("min_", feature_name) := min(!! feature))
}
# Going to construct permutations of object and measure to input to get_max_min
object <- c("Sepal", "Petal")
measure <- c("Width", "Length")
dfs <- expand.grid(object = object,measure = measure)
dfs <- dfs %>% mutate(features = paste0(object,".",measure ))
for (i in seq_along(dfs$features)) {
txt_feature <- dfs$features[[i]]
dfs$Max_Min_Output[[i]] <- get_max_min(iris, !! sym(txt_feature)) # THIS IS THE THING GLUED IT TOGETHER
}
df_combined <- reduce(dfs$Max_Min_Output, full_join, by = "Species")
IRL I'm going to end up with ~16 features summarized in a bunch of different ways taking max and min and snapshot values when varying conditions are met and then aggregated into common buckets. The iris example probably doesn't convey how messy it would get, but I think this should work for me.
EDIT to say: as I look at this I wonder if I have done something incredibly convoluted and unnecessary by taking !! enquo(!! sym()). I started out trying to rewrite a bunch of code in this way as the requirements of the project keep expanding (and my code as been doubling each time). I also wanted to get a handle on quasiquotation. It's working now, but something about it feels not-quite-right. If anyone has any simplifying perspective on this it would be welcome. I'm not far into learning R and some of this stuff warps my brain.