hi I was trying to add a name column into all of the elements in my list using the names of the list. That is I have 8 tables in my list, each table has its own name table 1...8. So later I can unlist them and differentiate where the table comes from.
I have read this post and the code works. R - Add columns to dataframes in list by looping through elements in a vector
my_list <- Map(cbind, mylist, Cluster = names(mylist))
However, I don't quite understand the Map(). This is not the map() from Purrr package right? map() will take the arguments in order map(data, function). I checked in Rstudio help on Map, it looks more confusing. And if I'm to use the Purrr map function, I tried this
my_list2 <- map(mylist, function(x)cbind(x,Cluster = names(x)))
it did not work. could someone enlighten me how Map works and if I'm going to use map(), what are the changes I should do?