I prepare some tidy data from dozens of messy .csv files (different numbers of columns, different names, some extra semicolons etc.). The variable important for me are - luckily - named the same way.
That's why I decided to use code to select this particular variables.
df <- list.files(path="./", pattern = ".csv",full.names = FALSE) %>%
lapply(function(x) read_csv2(x, col_select = c("variable1","variable2"))) %>%
bind_rows
It works well, but I need also the variable with the name of a the file it comes from. The question is, how to add a variable with the source file name to the resulting data frame?