I am trying to create a tibble from a multitude of TSV-Textfiles. I first created a list containing the paths to my textfiles called text_files. I then tried to loop through these textfiles to create one dataframe with all info.
for (file_path in text_files) {
# Read in the TSV file
tibble <- read_tsv(file_path, col_names = TRUE)
# Extract file name for the TSV file
file_name <- basename(file_path)
# Add file name to tibble
tibble$file_name <- file_name
# Append the tibble to the all_data tibble
all_data <- bind_rows(all_data, tibble)
}
Back in February my script still worked.Now it crashes and gives me a fatal error.
I have narrowed down the issue and see that it comes from "read_tsv", because I can get it to crash using just this:
file_path <- text_files[[1]]
tibble <- read_tsv(file_path, col_names = TRUE)
file_path <- text_files[[2]]
tibble <- read_tsv(file_path, col_names = TRUE)
As soon as I try to overwrite the tibble (or even save it as a new tibble), R crashes because of a fatal error. This happens only for a specific textfile - the ones with only 1 line of data work fine, and the ones with 9 lines of data cause the crash, but only if I read in another textfile with 9 lines of data before.
Does anyone know what the issue seems to be here, and more importantly how to fix it so I can read in all my data?
When playing around with it, I renamed file_path and tibble to other names, and got it to work once without crashing, but not reproducibly so.
Edit: Now it sometimes crashes even at the first try.