I have a list, list_df, and I'd like to add a column using mutate to each element within the list to reflect which element it is located in.
df1 <- tibble(M = words[sample(1:length(words), 10)],
                  N = rnorm(10, 3, 3)) 
df2 <- tibble(M = words[sample(1:length(words), 10)],
              N = rnorm(10, 3, 3))
df3 <- tibble(M = words[sample(1:length(words), 10)],
              N = rnorm(10, 3, 3))
list_df <- list(df1, df2, df3)
I can't seem to find a function that can extract the element names, similar to rownames(). I think the code would have to involve map( ~ mutate(.))?
The third element in my end output would look like this:
[[3]]
# A tibble: 10 x 3
   M              N  page
   <chr>      <dbl> <dbl>
 1 really     9.86      3
 2 son        3.34      3
 3 fair       0.660     3
 4 local      0.664     3
 5 out        3.76      3
 6 high       6.62      3
 7 condition  5.24      3
 8 cat        1.03      3
 9 meaning    3.39      3
10 account   -0.702     3