Here are two possible approaches: a solution for EDIT using compounds is more flexible and efficient.
Use write.table(...,append = T)andcat
- Use
append=Tin a call write.tablewith cata header earlier
wrapped in its own function ....
write.table_with_header <- function(x, file, header, ...){
cat(header, '\n', file = file)
write.table(x, file, append = T, ...)
}
, append write.csv,
write.table_with_header(x,file,header,sep=',')
csv.
( @flodel, )
my.write <- function(x, file, header, f = write.csv, ...){
datafile <- file(file, open = 'wt')
on.exit(close(datafile))
if(!missing(header)) writeLines(header,con=datafile)
f(x, datafile,...)
}
, write.csv write.table ,
( @flodel )
. !