I want to append the file name to my table, but it seems it is not really working.
What I am doing is iterating over a list of filenames, opening them, appending all the data to one data frame and for each appended file I want to add its file name. I expect it to be appended on each row, so that later when I look at the data, I would know from which file is the given row originating.
But it seems that it is not working as expected.
data <- data.frame()
for (file in files){
name = strsplit(file, split = "\\.")[[1]][1]
data <- data %>% bind_rows(read_delim(file = file, delim = ";", col_types = cols(
a = col_double(),
b = col_double(),
)) %>% mutate(name = name))
}
I believed that the mutate function should have done the trick, apparently, in the end they all have the same value.