Skip to content
Prev 256713 / 398506 Next

strategy for writing out file with lines header initiated with comment sign

Here is an outline of how to do it using connections:

con <- file('/temp/mytemp.txt', 'w')
writeLines(c("#comment", "# lines", "# in the file"), con = con)
# create some data to be output as 'tab' separated
myData <- as.data.frame(matrix(letters[1:25], 5))
write.table(myData, file = con, sep = '\t')
close(con)
con <- file('/temp/mytemp.txt', 'w')
writeLines(c("#comment", "# lines", "# in the file"), con = con)
# create some data to be output as 'tab' separated
myData <- as.data.frame(matrix(letters[1:25], 5))
write.table(myData, file = con, sep = '\t')
close(con)
On Wed, Apr 13, 2011 at 6:15 AM, Mao Jianfeng <jianfeng.mao at gmail.com> wrote: