Basically, what i want to do is to add column names to my files, in one piece of code. For a single file, the code would be:
data <- read.table("file", sep = "\t", header = FALSE)
names(data)
colnames(data) <- a
write.table(data, "file", sep = "\t", col.names = TRUE, row.names = FALSE)
I'm trying to optimise my code, so I can do all of them without having to type in my Rmarkdown document 8 times the same code (one for each file)
What error do you get? What is it that you would like to get out of the loop? The same files but now with change of header?