title: looping over all combinations in a tibble
body: <p>I would like to create an index based on n for each combination of LZCODE(data below) and Bereich over 4 years and then rbind those indices in order to plot them later. As the example below shows, I can do that by hand. However that process is quite tedious and would take a lot of time. Hence, I am looking for a loop solution based on that code.</p>
  <pre><code>a&lt;- trail2 %&gt;% filter(LZCODE == 31 &amp; Bereich == 11) %&gt;% transform(.index=100*n/n[1])
  </code></pre>
  <p><a href="https://i.stack.imgur.com/gTOjJ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/gTOjJ.png" alt="enter image description here" /></a></p>
  <pre><code>b&lt;- trail2 %&gt;% filter(LZCODE == 41 &amp; Bereich == 11) %&gt;% transform(.index=100*n/n[1])
  
  final&lt;- bind_rows(a,b)
  </code></pre>
  <p>Thanks fo your help.</p>
  <p>Data:</p>
  <pre><code>structure(list(Jahr = c(&quot;1985&quot;, &quot;1997&quot;, &quot;2009&quot;, &quot;2018&quot;, &quot;1985&quot;, 
  &quot;2018&quot;, &quot;1997&quot;, &quot;1997&quot;, &quot;2009&quot;, &quot;2009&quot;, &quot;2018&quot;, &quot;1985&quot;, &quot;1997&quot;, 
  &quot;1985&quot;, &quot;2018&quot;, &quot;2009&quot;, &quot;1997&quot;, &quot;1985&quot;, &quot;2009&quot;, &quot;2018&quot;, &quot;1997&quot;, 
  &quot;2009&quot;, &quot;2018&quot;, &quot;1985&quot;, &quot;1985&quot;, &quot;1997&quot;, &quot;1985&quot;, &quot;1997&quot;, &quot;1985&quot;, 
  &quot;2018&quot;, &quot;1985&quot;, &quot;2009&quot;, &quot;2018&quot;, &quot;2009&quot;, &quot;1997&quot;, &quot;1997&quot;, &quot;2009&quot;, 
  &quot;2009&quot;, &quot;2018&quot;, &quot;2018&quot;, &quot;1985&quot;, &quot;2018&quot;, &quot;1997&quot;, &quot;2009&quot;, &quot;2009&quot;, 
  &quot;1985&quot;, &quot;1997&quot;, &quot;2018&quot;, &quot;1985&quot;, &quot;2009&quot;), Bereich = c(41, 41, 
  41, 41, 46, 50, 46, 50, 50, 46, 46, 50, 50, 50, 50, 50, 50, 50, 
  50, 50, 50, 50, 50, 42, 50, 50, 50, 50, 50, 50, 42, 50, 50, 50, 
  42, 42, 42, 42, 42, 42, 42, 43, 42, 43, 42, 41, 41, 42, 42, 41
  ), LZCODE = c(&quot;31&quot;, &quot;31&quot;, &quot;31&quot;, &quot;31&quot;, &quot;61&quot;, &quot;61&quot;, &quot;61&quot;, &quot;61&quot;, 
  &quot;61&quot;, &quot;61&quot;, &quot;61&quot;, &quot;61&quot;, &quot;31&quot;, &quot;31&quot;, &quot;31&quot;, &quot;31&quot;, &quot;52&quot;, &quot;52&quot;, &quot;52&quot;, 
  &quot;52&quot;, &quot;53&quot;, &quot;53&quot;, &quot;53&quot;, &quot;31&quot;, &quot;53&quot;, &quot;41&quot;, &quot;41&quot;, &quot;51&quot;, &quot;51&quot;, &quot;41&quot;, 
  &quot;52&quot;, &quot;51&quot;, &quot;51&quot;, &quot;41&quot;, &quot;31&quot;, &quot;52&quot;, &quot;52&quot;, &quot;31&quot;, &quot;52&quot;, &quot;31&quot;, &quot;51&quot;, 
  &quot;31&quot;, &quot;51&quot;, &quot;31&quot;, &quot;51&quot;, &quot;41&quot;, &quot;41&quot;, &quot;51&quot;, &quot;41&quot;, &quot;41&quot;), n = c(346887L, 
  337676L, 318685L, 306823L, 211663L, 208646L, 206245L, 205096L, 
  204536L, 203806L, 198548L, 197565L, 186488L, 184819L, 182115L, 
  169676L, 139706L, 138860L, 135337L, 134505L, 95389L, 94861L, 
  94638L, 93322L, 92285L, 89329L, 88517L, 87410L, 86739L, 86506L, 
  83848L, 83366L, 83361L, 83249L, 82756L, 81789L, 80460L, 79102L, 
  78429L, 77593L, 62154L, 61167L, 59448L, 58686L, 57644L, 56588L, 
  56517L, 55279L, 54327L, 53842L), Bezeichnung = c(&quot;Ackerland&quot;, 
  &quot;Ackerland&quot;, &quot;Ackerland&quot;, &quot;Ackerland&quot;, &quot;Günstige Alp- und Juraweiden&quot;, 
  &quot;Normalwald&quot;, &quot;Günstige Alp- und Juraweiden&quot;, &quot;Normalwald&quot;, &quot;Normalwald&quot;, 
  &quot;Günstige Alp- und Juraweiden&quot;, &quot;Günstige Alp- und Juraweiden&quot;, 
  &quot;Normalwald&quot;, &quot;Normalwald&quot;, &quot;Normalwald&quot;, &quot;Normalwald&quot;, &quot;Normalwald&quot;, 
  &quot;Normalwald&quot;, &quot;Normalwald&quot;, &quot;Normalwald&quot;, &quot;Normalwald&quot;, &quot;Normalwald&quot;, 
  &quot;Normalwald&quot;, &quot;Normalwald&quot;, &quot;Naturwiesen&quot;, &quot;Normalwald&quot;, &quot;Normalwald&quot;, 
  &quot;Normalwald&quot;, &quot;Normalwald&quot;, &quot;Normalwald&quot;, &quot;Normalwald&quot;, &quot;Naturwiesen&quot;, 
  &quot;Normalwald&quot;, &quot;Normalwald&quot;, &quot;Normalwald&quot;, &quot;Naturwiesen&quot;, &quot;Naturwiesen&quot;, 
  &quot;Naturwiesen&quot;, &quot;Naturwiesen&quot;, &quot;Naturwiesen&quot;, &quot;Naturwiesen&quot;, &quot;Naturwiesen&quot;, 
  &quot;Heimweiden&quot;, &quot;Naturwiesen&quot;, &quot;Heimweiden&quot;, &quot;Naturwiesen&quot;, &quot;Ackerland&quot;, 
  &quot;Ackerland&quot;, &quot;Naturwiesen&quot;, &quot;Naturwiesen&quot;, &quot;Ackerland&quot;), Bezeichnung_trim = c(&quot;Ackerland&quot;, 
  &quot;Ackerland&quot;, &quot;Ackerland&quot;, &quot;Ackerland&quot;, &quot;Günstige\nAlp- und\nJuraweiden&quot;, 
  &quot;Normalwald&quot;, &quot;Günstige\nAlp- und\nJuraweiden&quot;, &quot;Normalwald&quot;, 
  &quot;Normalwald&quot;, &quot;Günstige\nAlp- und\nJuraweiden&quot;, &quot;Günstige\nAlp- und\nJuraweiden&quot;, 
  &quot;Normalwald&quot;, &quot;Normalwald&quot;, &quot;Normalwald&quot;, &quot;Normalwald&quot;, &quot;Normalwald&quot;, 
  &quot;Normalwald&quot;, &quot;Normalwald&quot;, &quot;Normalwald&quot;, &quot;Normalwald&quot;, &quot;Normalwald&quot;, 
  &quot;Normalwald&quot;, &quot;Normalwald&quot;, &quot;Naturwiesen&quot;, &quot;Normalwald&quot;, &quot;Normalwald&quot;, 
  &quot;Normalwald&quot;, &quot;Normalwald&quot;, &quot;Normalwald&quot;, &quot;Normalwald&quot;, &quot;Naturwiesen&quot;, 
  &quot;Normalwald&quot;, &quot;Normalwald&quot;, &quot;Normalwald&quot;, &quot;Naturwiesen&quot;, &quot;Naturwiesen&quot;, 
  &quot;Naturwiesen&quot;, &quot;Naturwiesen&quot;, &quot;Naturwiesen&quot;, &quot;Naturwiesen&quot;, &quot;Naturwiesen&quot;, 
  &quot;Heimweiden&quot;, &quot;Naturwiesen&quot;, &quot;Heimweiden&quot;, &quot;Naturwiesen&quot;, &quot;Ackerland&quot;, 
  &quot;Ackerland&quot;, &quot;Naturwiesen&quot;, &quot;Naturwiesen&quot;, &quot;Ackerland&quot;)), row.names = c(NA, 
  -50L), groups = structure(list(Jahr = c(&quot;1985&quot;, &quot;1985&quot;, &quot;1985&quot;, 
  &quot;1985&quot;, &quot;1997&quot;, &quot;1997&quot;, &quot;1997&quot;, &quot;1997&quot;, &quot;2009&quot;, &quot;2009&quot;, &quot;2009&quot;, 
  &quot;2009&quot;, &quot;2009&quot;, &quot;2018&quot;, &quot;2018&quot;, &quot;2018&quot;, &quot;2018&quot;, &quot;2018&quot;), Bereich = c(41, 
  42, 46, 50, 41, 42, 46, 50, 41, 42, 43, 46, 50, 41, 42, 43, 46, 
  50), .rows = structure(list(c(1L, 46L), c(24L, 31L, 41L, 49L), 
      5L, c(12L, 14L, 18L, 25L, 27L, 29L), c(2L, 47L), c(35L, 36L, 
      43L), 7L, c(8L, 13L, 17L, 21L, 26L, 28L), c(3L, 50L), c(37L, 
      38L, 45L), 44L, 10L, c(9L, 16L, 19L, 22L, 32L, 34L), 4L, 
      c(39L, 40L, 48L), 42L, 11L, c(6L, 15L, 20L, 23L, 30L, 33L
      )), ptype = integer(0), class = c(&quot;vctrs_list_of&quot;, &quot;vctrs_vctr&quot;, 
  &quot;list&quot;))), row.names = c(NA, -18L), class = c(&quot;tbl_df&quot;, &quot;tbl&quot;, 
  &quot;data.frame&quot;), .drop = TRUE), class = c(&quot;grouped_df&quot;, &quot;tbl_df&quot;, 
  &quot;tbl&quot;, &quot;data.frame&quot;))
  </code></pre>