Consider that I have a function f(x,y)
that takes two argument and two lists
x_var = list('x','y','z')
- and
y_var = list('a','b')
Is there a purrr
function that allows me to iterate every combination of one element in x_var
and one element in y_var
? That is, doing f(x,a)
, f(x,b)
, f(y,a)
, f(y,b)
etc.
The usual solution would be to write a loop, but I wonder if there is more concise here (possibly with purrr
.
Thanks!
You can use one of the
cross*
functions along withmap
: