You can get all the files and then loop using lapply
and apply whatever function you want to apply as follows:
files <- list.files(path="path/to/dir", pattern="*.txt", full.names=TRUE, recursive=FALSE)
lapply(files, function(x) {
t <- read.table(x, header=TRUE) # load file
# apply function
out <- function(t)
# write to file
write.table(out, "path/to/output", sep="", quote=FALSE, row.names=FALSE, col.names=TRUE)
})
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…