I have a list of named dataframes and run a function on them as below.
I need to get the name of the dataframe whilst running the function.
In the example below I want to add a column with the name of the dataframe in and have entered paste0("df_name")
as a placeholder. How can I replace this to get the name of the actual dataframe?
library(tidyverse)
df_list<-list()
df_list$iris1<-iris[1:50,]
df_list$iris2<-iris[51:100,]
df_list$iris3<-iris[101:150,]
df_name<-function(df){
df%>%
mutate(df_name=paste0("df_name"))
}
map(df_list,df_name)