If I have a list of data frames
my_list = list(data, data2, data3)
and I would like to add a column to each that is populated with that data frame's name
column1 column2 new_column
12 27 data
27 987 data
378 1234 data
, how would I go about this? I would like all DFs within the set to retain their original names, but have it populate a column, as well.
I have tried:
my_list = lapply(my_list, function(DF){
DF$new_column <- DF
DF
})
but it doesn't run through the list within the function.
What am I missing? Thanks