[R] write.csv and header

Patrick Connolly p_connolly at slingshot.co.nz
Wed Dec 16 20:49:24 CET 2009


On Tue, 15-Dec-2009 at 01:55PM +0100, Gustaf Rydevik wrote:


|> Hi,
|> 
|> ?write.table and the argument "append" should be of help.
|> example:
|> 
|> > sink("test.csv")
|> > cat("-----------------------------")
|> > cat("\n")
|> > cat("This is \n a test of header")
|> > cat("\n")
|> > cat("-----------------------------")
|> > cat("\n")
|> > sink()
|> >

Or, instead of the use of sink() and cat(), one could use the write()
function, also using the append = TRUE argument.


|> write.table(matrix(rnorm(100),nrow=10),file="test.csv",append=TRUE,sep=",")
|> 
|> 
|> regards,
|> Gustaf
|> 
|> 
|> -- 
|> Gustaf Rydevik, M.Sci.
|> tel: +46(0)703 051 451
|> address:Essingetorget 40,112 66 Stockholm, SE
|> skype:gustaf_rydevik
|> 
|> 	[[alternative HTML version deleted]]
|> 
|> ______________________________________________
|> 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.

-- 
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.   
   ___    Patrick Connolly   
 {~._.~}                   Great minds discuss ideas    
 _( Y )_  	         Average minds discuss events 
(:_~*~_:)                  Small minds discuss people  
 (_)-(_)  	                      ..... Eleanor Roosevelt
	  
~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.




More information about the R-help mailing list