I have some existing code that looks like this
library(dplyr) iris %>% mutate(output = purrr::invoke(pmin, across(starts_with("Sepal"))))
There are many columns that need to be included, so it would be better to not have to write them out.
There are two problems with this code
invokeis deprecated, and
- It looks unnecessarily (maybe?) complicated
The change suggested by the help file returns an error ie just placing "!!!" in front of
# Before: invoke(mean, list(na.rm = TRUE), x = 1:10) # After exec(mean, 1:10, !!!list(na.rm = TRUE))
Anyway, I can't remember why I wrote the code the way that I did, it seems unnecessarily complex. Am I missing some obvious way to compute a function mapping a subset of columns to one column?