Assuming there is a column called year
in each of the file you can try :
files <- list.files(pattern = '*.txt', full.names = TRUE)
lapply(files, function(x) {
tmp <- subset(read.table(x), !year %in% c(1982, 1983, 1997, 1998))
write.table(tmp, paste0(tools::file_path_sans_ext(basename(x)), '_new.txt'))
})
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…