On 4/2/2006 9:38 PM, ivo welch wrote:
> Dear R group:  Is there a way to pass a comment line to write.table()
> or write.csv()?  presumably, following linux and R conventions, it
> would be preceded by a '#' in the output.
> 
> write.csv( object, file="object.csv", comment=paste("this csv file was
> created by mycode.R on 12/2/2005");
> 
> of course, the R read functions are already smart enough to ignore the
> comment lines.

Open a connection, write the comment to the connection, write the data 
to the connection, close the connection.

e.g.

con <- file("object.csv", open="wt")
writeLines(paste("# this csv file was created by mycode.R on 
12/2/2005"), con)
write.csv( object, con)
close(con)

Duncan Murdoch

______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to