Loop through files in directory

Hi Friends.

I have been wondering if it is possible to make a loop in file directory, I would like to change the txt file whenever code run is finished and then keep going to the next file...

For instance: I want to change FileGD automatically, when the code is finished. and run again for the next txt file.

Can you help me?


FileGD = ("Matrix1.txt")

ColumnName<- data.frame(fread(file = FileGD, header = FALSE, sep = "\t"))[1,]
MatrixGD<- data.frame(fread(file = FileGD, header = TRUE, sep = "\t"))
colnames(MatrixGD)<- c(ColumnName)

GDFile<-cbind(MatrixGD[1], stack(lapply(MatrixGD[2:Num.C], as.character)))
colnames(GDFile)<- c("Hybrids", "GD", "Tester")

GDFile2<- str_c(GDFile$Hybrid, "/", GDFile$Tester)

GDFinal<- data.frame(GDFile2, GDFile[2])
colnames(GDFinal)<- c("Hybrids", "GD")

fwrite(GDFinal, "ArquivoGD.txt", row.names = FALSE, sep = "\t")


This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.