[R] Writing out data

Ivan Calandra ivan.calandra at u-bourgogne.fr
Thu Feb 2 13:56:56 CET 2012

Correct me if I'm wrong, but I think that write.csv() doesn't have an 
append argument; write.table() does though.


Université de Bourgogne
UMR CNRS/uB 6282 Biogéosciences
6 Boulevard Gabriel
21000 Dijon, FRANCE
ivan.calandra at u-bourgogne.fr

Le 02/02/12 13:43, Paul Hiemstra a écrit :
> On 02/02/2012 11:40 AM, Thomas wrote:
>> What is the best way to write out comma separated data, as a program
>> is running (rather than waiting to the end using write.csv)? At the
>> moment I'm doing this, but I guess it's not the most efficient. The
>> data is in a column in the matrix postcount, and I'm using a loop to
>> write out each of the 100 elements.
>> for (j in 1:100)
>> {
>> cat(postcount[1,j], ",", file=filename, append=TRUE)
>> }
>> cat("\n", file=filename, append=TRUE)
>> Thank you!
>> Thomas
>> This message and any attachment are intended solely for the addressee
>> and may contain confidential information. If you have received this
>> message in error, please send it back to me, and immediately delete
>> it.   Please do not use, copy or disclose the information contained in
>> this message or in any attachment.  Any views or opinions expressed by
>> the author of this email do not necessarily reflect the views of the
>> University of Nottingham.
>> This message has been checked for viruses but the contents of an
>> attachment
>> may still contain software viruses which could damage your computer
>> system:
>> you are advised to perform your own checks. Email communications with the
>> University of Nottingham may be monitored as permitted by UK legislation.
>> ______________________________________________
>> R-help at 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.
> Hi,
> write.csv also supports an append argument. Maybe that is faster than
> using cat.
> cheers,
> Paul

More information about the R-help mailing list