I have five text files created by the R program (each of which has a header) that should be combined into one file. I combined them with rbind , and my problem is when I combine them, the resulting output has headers attached at the end of each file, for example, if the headers are assumed
Combine Resultant file ABCD 1 3 5 7 ------------> Text file1 6 9 0 3 ABCD 1 3 6 7 ------------> Text file 2 5 7 8 3 and so on....
instead, I want the output file to have only one header in line 1 so the file should look like this:
Combine Resultant file ABCD 1 3 5 7 ------------> Text file1 6 9 0 3 1 3 6 7 ------------> Text file 2 5 7 8 3 and so on....
Can someone tell me how to do this? The code I have is:
S1 <- read.table("C:/Simulation_Results/sim_1_200.txt",sep=";",header= TRUE); S2 <- read.table("C:/Simulation_Results/sim_201_400.txt", sep=";",header= TRUE); S3 <- read.table("C:/Simulation_Results/sim_401_600_b.txt", sep=";",header= TRUE); S4 <- read.table("C:/Simulation_Results/sim_601_800.txt", sep=";",header= TRUE); S5 <- read.table("C:/Simulation_Results/sim_901_1000.txt",sep=";",header= TRUE); S6 <- read.table("C:/Simulation_Results/simulations_801_900.txt",sep=";",header= TRUE); options(max.print=28.5E6); S7 <- rbind(S1,S2,S3,S4,S5,S6) write.table(S7, file="C:/Simulation_Results/simulation_1_1000.txt", sep=";", row.names=TRUE, col.names=FALSE, quote = FALSE);
Thanks!