I would like to use pmap with non standard evaluation.
I have tried with a small example but it does not work.
library(tidyverse)
library(magrittr)
#>
#> Attachement du package : 'magrittr'
#> The following object is masked from 'package:purrr':
#>
#> set_names
#> The following object is masked from 'package:tidyr':
#>
#> extract
df <- tibble(
x = 1:3 + 0.1,
y = 3:1 - 0.1
)
test_func <- function(x, y){
x + y
}
# Work:
df %>%
mutate(
test = pmap_dbl(
list(x = x, y = y),
test_func)
)
#> # A tibble: 3 x 3
#> x y test
#> <dbl> <dbl> <dbl>
#> 1 1.1 2.9 4
#> 2 2.1 1.9 4
#> 3 3.1 0.9 4
# NSE does not work:
df %>%
mutate(
test = pmap_dbl(
list(x = x, y = y),
~test_func(x = x, y = y))
)
#> Error: Evaluation error: Result 1 is not a length 1 atomic vector.
Created on 2019-03-28 by the reprex package (v0.2.0.9000).
I expect that NSE output is the same than the "usual" equivalent of pmap.