Note that there are some explanatory texts on larger screens.

plurals
  1. POCombine the multiple files with one header
    primarykey
    data
    text
    <p>I have five text files that are produced by an <code>R</code> program, (each of them having header) that are to be combined into a single file. I have combined them using <code>rbind</code> and my problem is when I combine them, the resultant output has headers attached at end of each file for example, if the headers are supposed </p> <pre><code>Combine Resultant file A B C D 1 3 5 7 ------------&gt; Text file1 6 9 0 3 A B C D 1 3 6 7 ------------&gt; Text file 2 5 7 8 3 and so on.... </code></pre> <p>instead of that I want the output file to have only one header at line 1 so the file should look like:</p> <pre><code>Combine Resultant file A B C D 1 3 5 7 ------------&gt; Text file1 6 9 0 3 1 3 6 7 ------------&gt; Text file 2 5 7 8 3 and so on.... </code></pre> <p>Can anyone tell me how to do that? The code I have is:</p> <pre><code>S1 &lt;- read.table("C:/Simulation_Results/sim_1_200.txt",sep=";",header= TRUE); S2 &lt;- read.table("C:/Simulation_Results/sim_201_400.txt", sep=";",header= TRUE); S3 &lt;- read.table("C:/Simulation_Results/sim_401_600_b.txt", sep=";",header= TRUE); S4 &lt;- read.table("C:/Simulation_Results/sim_601_800.txt", sep=";",header= TRUE); S5 &lt;- read.table("C:/Simulation_Results/sim_901_1000.txt",sep=";",header= TRUE); S6 &lt;- read.table("C:/Simulation_Results/simulations_801_900.txt",sep=";",header= TRUE); options(max.print=28.5E6); S7 &lt;- 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); </code></pre> <p>Thanks!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload