May be this question termed as part-3 of this question.
I know that arguments in lambda functions when used in tidyverse
especially purrr
functions are written as -
.
when there is only 1 argument.x
&.y
when there are 2- OR
..1
,..2
so on when there are> 2
arguments
In the linked question, I learnt that if all the arguments have to be simultaneously passed we may use ellipsis i.e. ...
.
But my question, why such ...
work only when wrapped inside a c()
and doesn't work when used as such. In the below two syntaxes, second one works while first one doesn't?
#1 this doesn't work
pmap_df(iris[1:4], ~...)
Error in .f(Sepal.Length = .l[[1L]][[i]], Sepal.Width = .l[[2L]][[i]], :
'...' used in an incorrect context
#2 this however, works and returns the first argument after converting it to a tibble
pmap_df(iris[1:4], ~ c(...))
#see
identical(pmap_df(iris[1:4], ~c(...)), iris[1:4] %>% as_tibble())
[1] TRUE
Can someone explain?