Hi guys! I need help in setting a for
loop in R (I'm quite new programming in R). I would like to add the same header to all the files that match a concrete pattern inside a folder.
To get the list of files I'm using the following code:
filelist <- list.files(pattern = "DESeq2_result*")
And this is the for
loop I am trying to implement:
for (i in seq_along(filelist)) {
names[[i]] <- a
out [i]
}
where a
is a vector that I defined with the names of the different columns:
a <- c("gene_id", "baseMean", "log2FC",
"SD", "WaldStatistic", "pval", "padj")
If you have any tutorial/page to help me to learn and practise my ability to code functions and loops in R would be so much appreciated.
Thank you so much in advance!
Jordi
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?