title: create a name variable in a dataframe from each list's name in purrr
body: <p>I want to take a data frame from my list and add to it another column with the name variable, same as lists name. and I want to achieve that using purrr. any other solutions are also welcome!</p>
  
  <pre><code>dat_list &lt;- list(a = as_tibble(rnorm(5)), b= as_tibble(rnorm(5)))
  
  dat_list
  $a
  # A tibble: 5 x 1
         value
         &lt;dbl&gt;
  1 -1.0946024
  2  0.1010983
  3 -0.1817757
  4  0.5394615
  5 -1.4450060
  
  $b
  # A tibble: 5 x 1
          value
          &lt;dbl&gt;
  1 -0.58095984
  2  0.50843100
  3 -0.01598389
  4  0.05894331
  5  0.36958224
  
  
  map2(.x = dat_list,.y = names(dat_list) ,.f = function(x){.y %&gt;% mutate(var &lt;- .x)})
  </code></pre>