All your files are being read, but the information is being overwritten onto data.2002
every time so in the end you only see the final file. You need to put first all of your data in a list at the end of the loop with an index.
EDIT: As noted by Nick below, your file.type
variable (which should be called file_list or something) should have the actual length of the files, otherwise you may end up with subscript errors (added some similar code)
files <- list.files(path_to_your_folder, pattern = ".dat", recursive = TRUE, include.dirs = FALSE)
data.2002 <- list()
counter <- 1
for(i in files) {
tempFile < -read.delim(file.path(path_to_your_folder, i)))
...
<Here your modifications to tempFile>
...
data.2002[[counter]] <- tempFile
counter <- counter + 1
}
Then, you can bind rows afterwards, for which there are at least a couple of ways:
df <- do.call("rbind", listOfDataFrames)
dplyr::bind_rows(list_of_dataframes, .id = "column_label")