title: Using purrr::map2 when one variable is not part of the function
body: <p>If I had a function like this:</p>
  
  <pre><code>foo &lt;- function(var) {
    if(length(var) &gt; 5) stop("can't be greater than 5")
  
    data.frame(var = var)
  }
  </code></pre>
  
  <p>Where this worked:</p>
  
  <pre><code>df &lt;- 1:20
  
  foo(var = df[1:5])
  </code></pre>
  
  <p>But this didn't:</p>
  
  <pre><code>foo(var = df)
  </code></pre>
  
  <p>The desired output is:</p>
  
  <pre><code>   var
  1    1
  2    2
  3    3
  4    4
  5    5
  6    6
  7    7
  8    8
  9    9
  10  10
  11  11
  12  12
  13  13
  14  14
  15  15
  16  16
  17  17
  18  18
  19  19
  20  20
  </code></pre>
  
  <p>If I know that I can only run this function in chunk of 5 rows, what would be the best approach if I wanted to evaluate all 20 rows? Can I use <code>purrr::map()</code> for this? Assume that the 5 row constraint is rigid. </p>
  
  <p>Thanks in advance.</p>