Hi.
I created a mapper function using purrr::as_mapper()
which converts tbl
numeric vars into log
values. It takes 3 arguments :1) a tbl 2) frac : a numeric value to be added before applying log and 3) a positive number with respect to which log are computed.
See the reproducible example below. The function is working as expected.
My question is

Why do I need to unquote arguments 2 and argument 3 (
!!..2
and!!..3
) insidemutate_if
and not argument 1 (..1
) ? 
While calling the mapper function, why do any random names assigned to arguments 1 and 2 works ?
library(tidyverse)
log_tbl < purrr::as_mapper(~ (..1 %>% dplyr::mutate_if(is.numeric , ~ log(. + !!..2 ,base = !!..3) )))
tbl < tibble::tibble(x = letters[1:5] , y = LETTERS[1:5] , z = 1:5 )
tbl
#> # A tibble: 5 x 3
#> x y z
#> <chr> <chr> <int>
#> 1 a A 1
#> 2 b B 2
#> 3 c C 3
#> 4 d D 4
#> 5 e E 5
tbl %>% log_tbl(0.1 , 2)
#> # A tibble: 5 x 3
#> x y z
#> <chr> <chr> <dbl>
#> 1 a A 0.138
#> 2 b B 1.07
#> 3 c C 1.63
#> 4 d D 2.04
#> 5 e E 2.35
tbl %>% log_tbl(frac = 0.1 , base= 2)
#> # A tibble: 5 x 3
#> x y z
#> <chr> <chr> <dbl>
#> 1 a A 0.138
#> 2 b B 1.07
#> 3 c C 1.63
#> 4 d D 2.04
#> 5 e E 2.35
^{Created on 20191022 by the reprex package (v0.3.0)}