I'm curious why the purrr::map_* function family, despite being a part of tidyverse, does not support quasiquotation by splice-unquoting its dots prior to evaluation of the mapped function?
library(tidyverse)
library(rlang)
set.seed(1)
dots <- quos(digits = 2L)
# this obviously won't work
purrr::map_chr(rnorm(5L),
~ format(.x, !!!dots))
#> Error in !dots: invalid argument type
# I'm confused why this does not work
purrr::map_chr(rnorm(5L),
~ format(.x, ...),
!!!dots)
#> Error in !dots: invalid argument type
# Finally, this works
eval_tidy(expr(
purrr::map_chr(rnorm(5L),
~ format(.x, ...),
!!!dots)
))
#> [1] "1.5" "0.39" "-0.62" "-2.2" "1.1"
Created on 2019-01-31 by the reprex package (v0.2.0).