[R] write.csv and header

John Kane jrkrideau at yahoo.ca
Wed Dec 16 23:55:19 CET 2009


Just write the headers once and append as many times as needed?

You can append as many datasets as you want.



--- On Wed, 12/16/09, rkevinburton at charter.net <rkevinburton at charter.net> wrote:

> From: rkevinburton at charter.net <rkevinburton at charter.net>
> Subject: Re: [R] write.csv and header
> To: "Gustaf Rydevik" <gustaf.rydevik at gmail.com>, "Patrick Connolly" <p_connolly at slingshot.co.nz>
> Cc: r-help at r-project.org
> Received: Wednesday, December 16, 2009, 3:05 PM
> 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.
> 
> ______________________________________________
> 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.
> 


      __________________________________________________________________
Be smarter than spam. See how smart SpamGuard is at giving ju



More information about the R-help mailing list