Say for instance I'm trying to use purrr::map2() to iterate rnorm() over a vector and I want to specify the options n and sd but not mean.
Using the "formula" way, I could do this:
len <- c(1, 3, 10); sigma <- c(1, 1, 10)
set.seed(123)
map2(len, sigma, ~rnorm(n = .x, sd = .y))
But is it possible to specify n and sd without specifying mean with the "function" way? If I do the following, it fills "sigma" in for mean because mean is the next option in rnorm() after n.
set.seed(123)
map2(len, sigma, rnorm)
I could specify that mean is 0 so that "sigma" would apply to sd, as below:
set.seed(123)
map2(len, sigma, rnorm, mean = 0)
But what if I wanted to leave mean at its default (without specifying it) and still have "sigma" apply to sd? As in, is there a way to do something like .x/.y if I'm using the "function" method.
Sorry that was wordy. Thanks a lot!