So, I have had two questions here and I combined the solutions, but it seems I am not implementing them well. (Q1 Q2)
So, I am reading files using read_delim() and trying to filter out some data before saving them into one data type.
data <- data.frame()
for (file in files){
name = strsplit(file, split = "\\.")[[1]][1]
tmp <- data %>% bind_rows(read_delim(file = file, delim = ";", col_types = cols(
a = col_double(),
b = col_double(),
c = col_character()
)) %>% mutate(filename = name)
data_tmp <- tmp %>%
filter(!str_detect(c, 'a'))
data <- rbind(data, tmp_data)
}
Apparently, the problem I had in the first question has reappeared. Looks like that mutate(filename = name) always gets the value from the last element that was read.