I'm generating all possible combinations of two input variables and passing them as arguments to a custom function. This gives me the desired result but I don't really understand what the curly braces do and how this differs from "normal" ways of writing piped code in the tidyverse. Can someone explain?
And is this really an elegant approach? Can this be re-written in a better way?
I see. So { } allows the entire object to be passed "as-is" to the next function in the pipe. I suppose this is useful when functions do not have data as their first argument (such as map2() in this case).
Can you suggest a way of re-writing my code without use of the { }?
@cderv Thank you so much! I initially got an error after replacing map2() with pmap() but after re-reading Hadley's chapter on Functionals, I realized that the column names of the input tibble must match the parameter names defined in the function. That did the trick.