(As far as supplying arguments via a list)
I would have thought that the second example would have worked, but I have to really force it to accept the arguments with exec()
.
library(tidyverse)
df <- tibble(a = c(1,2,3,NA,5), b = a)
# works
map(df, sum, na.rm = TRUE)
#> $a
#> [1] 11
#>
#> $b
#> [1] 11
# doesn't work
map(df, sum, !!!list(na.rm = TRUE))
#> Error in !list(na.rm = TRUE): invalid argument type
# works with some effort
map(df, ~exec(sum, ., !!!list(na.rm = TRUE)))
#> $a
#> [1] 11
#>
#> $b
#> [1] 11
Created on 2021-06-17 by the reprex package (v1.0.0)