[R] write.csv and header

rkevinburton at charter.net rkevinburton at charter.net
Wed Dec 16 21:05:03 CET 2009


I have a small request regarding this "append" feature. As it is now if the data is appended to the file so is the header. I would like to have the header only entered once and appends just append the data.

Doable?

Kevin

---- Patrick Connolly <p_connolly at slingshot.co.nz> wrote: 
> 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
> 	  
> ~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.
> 
> ______________________________________________
> 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.




More information about the R-help mailing list