The code so far looks like this:
abc <- import_list(dir("MyData/", pattern = "*.xlsx",
full.names = TRUE), rbind = TRUE, rbind_label = "source")
Using the "rio" package this code imports many excel files at once putting one table under the other. The columns are sorted by column name (rbind = TRUE) in order to avoid a situation where data is put into the wrong columns (e.g. if some tables have more columns than others).
I want to have a FIRST column that entails the name of the excel file so that I know from where the data comes. However, there are two problems with rbind_label = "source"
- It creates a column but in that column it's not the name of the file, but the whole path of it (pretty long)
- The column is not at the beginning of the newly created table, but somewhere in the middle.
How can I solve these two problems?