I have a function which takes a column name as an input:
library(tidyverse)
dat <- diamonds
ex_func <- function(df, grp) {
df %>%
distinct(cut, get(grp))
}
ex_func(dat, grp = "color")
How exactly do I get the name of the second column in the resulting group to be the input (e.g. "color", rather than get(grp))?