write text in a table to export in r

2k Views Asked by At

I would like to export a table in R but i need 3 header lines, for example:

DATASET
#PAT: 60
#INPUT: 11 
#OUTPUT: 1

0   0   1   56.5    0   0   122 1   2   0   65000   0.5
0   0   1   33.5    0   0   145 1   2   0   70000   0.6
0   0   1   65.5    46  0   126 2   2   0   70000   0.7
0   0   1   33.5    0   0   130 1   2   0   60000   0.7
0   0   1   42.5    46  0   126 1   2   0   70000   0.8
.
.
.

Someone could help me?, Thanks

1

There are 1 best solutions below

0
JAponte On BEST ANSWER

Here it is:

cat('#PAT: 60\n', file='out.txt', append=F)
cat('#INPUT: 11\n', file='out.txt', append=T)
cat('#OUTPUT: 1\n', file='out.txt', append=T)
cat('\n', file='out.txt', append=T)
write.table(data.frame(A=1:4, B=3:6), 
            file='out.txt', append=T, sep='\t', 
            row.names=F, col.names=F)