title: How to use purrr::map2() with inconsistent vector lengths
body: <p>I want to produce summary statistics based on 4 different columns. The different summary statistics are calculated based on a label column (which has two values) and the different group columns (group 1, 2 and 3). Thus, you get different tbls for the Label1*group1, Label1*group2 etc. </p>
  
  <pre><code>set.seed(123)
  tbl &lt;- tibble(
         label  = rep(c("Label1", "Label2"), 6),
         group1  = rep(c("a", "b", "c", "d"), 3),
         group2  = rep(c("x", "y","z"), 4),
         group3  = rep(c("1", "1", "2", "2", "3", "3"), 2),
         value1 = rnorm(12, 100, 10),
         value2 = rnorm(12, 50, 5)
  )
  
  tbl
  </code></pre>
  
  <p>I made a sample function and I want the function to use the two vectors as the <code>.x</code> and the <code>.y</code> argument. </p>
  
  <pre><code>tmp_label &lt;- c("Label1", "Label2") # .x
  group &lt;- c("group1", "group2", "group3") # .y
  
  # .f
  tmp_function &lt;- function(Label, group) {
  
    tbl %&gt;% 
      filter(label %in% tmp_label) %&gt;% 
      group_by(group) %&gt;% 
      summarise(mean = mean(value1),
                mean2  = mean(value2)) %&gt;% 
      mutate(Label = tmp_label)
  
  }
  </code></pre>
  
  <p>Thus, I thought using <code>purrr::map2()</code> seemed the appriopiate function to get the different summary statistics. However, it produces an error which tells me that the mapped vectors must have consistent lengths. Thus my question is 1) is it possible to use <code>purrr</code> functions for inconstistent vector lengths and 2) if not, is there another (preferably tidy) way to get the different summary statistics. The produced error:</p>
  
  <pre><code>map2(.x = tmp_label, .y = group, .f = tmp_function)
  Error: Mapped vectors must have consistent lengths:
  * `.x` has length 2
  * `.y` has length 3
  </code></pre>
  
  <p>Any help would be much appreciated! </p>