I have a list of data frames and the names of the element list contains information about each data frame.
Here is a reproducible example,
list_df <- list(jan_2013 = data.frame(id = 1:10, x = rnorm(10), y = runif(10)),
feb_2013 = data.frame(id = 1:10, x = rnorm(10), y = runif(10)))
How can create a column in each data frame with the information contained in the element names?
I'm working with purrr
operations over the list, so how can use purrr::map
to iterate over each data frame and have access to the element name on which is store in the list?
$jan_2013
id x y meta_information
1 0.2 2.3 jan_2013
2 0.3 2.1 jan_2013
$feb_2013
id x y meta_information
1 0.1 2.4 feb_2013
2 1.4 2.1 feb_2013