I am importing multiple csv files from a list. I would like to add a column to each imported dataset with a unique name.
datasets <- list2env(lapply(setNames(temp_dirs, str_before_first(str_after_nth(temp_dirs, "/", -2),"/")), read.csv), .GlobalEnv)
temp_dirs
= a list of file paths
Each dataset is saved using a section of the file path name. For each dataset, I would like to add a column so that the file path (either a section or the entire path) is inserted into a column within each dataset. How can I do this?
Thanks