I am currently experiencing issues with a loop construct of mine. I loop over several data frames that are stored in a list. For each iteration, I would like to extract the name of the data frame to be then used as output name. I tried the following:
df_list<-list(df1, df2, df3) #Looping across list of data frames ... #Extract name of data frame: name<-paste0(as.character(df_list[[i]]), "result")
However, this approach extract the complete content of the data frame and uses it as variable name. I tried several other approaches, but all failed...
Thank you very much in advance!
Use tibble::lst() to create the list.. this function automatically uses the 'name' of the added object as name in the list, so it always returns a named list.
tibble::lst()
so df_list <- tibble::lst( df1, df2, df3 )
df_list <- tibble::lst( df1, df2, df3 )
2.1m questions
2.1m answers
60 comments
57.0k users