title: Multivariate R apply function
body: <p>I'd like to calculate weighted quantiles (reldist::wtd.quantile) over certain array margins using apply() but the function requires covariate weights for each observation.</p>
  <p>Is there a version of apply that would operate something like this:</p>
  <pre><code>myfunc &lt;- function(var1, var2) wtd.quantile(x = var1, weight = var2)
  
  out &lt;- apply(array1, array2, MARGIN=c(3,5,6), myfunc)
  
  </code></pre>
  <p>where the apply function knows to send array1 data as var1 and array2 data as var2?</p>
  <p>I'm about to make this function myself by vectorizing array1 and array2 and using purrr::map2 but wanted to check if a more efficient function already exists.</p>
  <p>Cheers!</p>