The situation arises where I open a file to write a data.frame to it. with
write.table.

multiple lines are written to the file and the file is kept in Append=TRUE
mode.

If one sets the col.names to the names of the variables being written,  you
have output
that looks like this...

name1 name2  name3.....

 x          x         x
 x          x         x
 x          x         x
name1  name2  name 3
 x          x         x
 x          x         x
 x          x         x

And so forth as each time write is called, the col.names are written.

Setting col.names=NULL obviously removes them.

I thought a simple solution would be to check for the file existence first
and on the first write, include the col.names. with append=T.
on subsequent writes, col.names would be set to NULL.
that didnt work and threw warnings.

Is there anyway to do this. basically open a file for writing, with
append=TRUE and only write the col.names once
at the first write. or am I stuck and forced to write the whole file without
the col.names and then read back in and rewrite
with col.names="the cols names I want"

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to