I have a folder which contains .txt files. The folder is called 'joined_data'. I want to read all the files into R so that they keep appending to the end of a single data frame called 'data'. That way all the data is combined into one data frame. I would like this to be automated.
I am currently trying to run this in a loop as shown below. However, it only keeps the last file in the data frame and deletes the rest.
library(here)
here()
#create list of files
files <- list.files(path=here('joined_data'),pattern = "\\.txt$")
## Iterates over the length of list
for (m in 1:length(files)){
data <- read.table(here('joined_data',paste('Chunk_',m,'_all.txt',sep='')), sep='\t', header=T, append = TRUE)
}