Is there a way to extract the input column names from the mutate
function?
Given any expressions, I ideally want an output telling me which columns were affected by the mutate call.
For example, I'm supplying a few tidy-based expressions to mutate
as shown below
library(dplyr)
out <- iris %>%
mutate(Species,
okay = Species,
across(c(Species, Sepal.Length), identity, .names = "{.col}_2"),
1:150,
.keep = "none")
names(out)
#> [1] "Species" "okay" "Species_2" "Sepal.Length_2"
#> [5] "1:150"
Created on 2023-04-20 with reprex v2.0.2
I'd like my output to essentially look something like this:
[1] "Species" "Species" "Species" "Sepal.Length" "1:150"