Re: [R] write.csv + appending output (FILE I/O)

From: Jason Barnhart <jasoncbarnhart_at_msn.com>
Date: Fri 19 May 2006 - 01:55:51 EST

When submitting your example under R.2.3.0 & WinXP, the resulting xls file was output row-wise as requested. See results below. Not sure why yours outputs columnar-wise.

To drop the variable name set col.names=FALSE. Note that the write.csv wrapper is designed to be inflexible and that you will need to use write.table instead. Here's a qoute from ?write.csv

"These wrappers are deliberately inflexible: they are designed to

     ensure that the correct conventions are used to write a valid
     file. Attempts to change 'col.names', 'sep', 'dec' or 'qmethod'
     are ignored, with a warning."

HTH,
-jason

Results from Sachin code.
****** Begin XLS File *******

      x
      1
      2
      3
      x
      1
      2
      3
      x
      1
      2
      3


> Hi,
>
> How can I write the output to an excel (csv) file without printing row
> names (i.e without breaks). Here is my code:
>
> library(
>
> fn <- function()
> {
> q <- c(1,2,3)
> write.csv(q,"C:/Temp/op.xls", append = TRUE, row.names = FALSE,quote =
> FALSE)
> }
>
> # Function Call
> for(i in 1:3)
> {
> fn()
> }
>
> Present Output :
> x 1 2 3 x 1 2 3 x 1 2 3
>
> Desired output:
> 1
> 2
> 3
> 1
> 2
> 3
> 1
> 2
> 3
>
> Also it displays following warning messages.
>
> Warning messages:
> 1: appending column names to file in: write.table(q, "C:/Temp/op.xls",
> 2: appending column names to file in: write.table(q, "C:/Temp/op.xls",
> 3: appending column names to file in: write.table(q, "C:/Temp/op.xls",
>
> I am using R2.2.1 windows version. I tried using write.xls from "marray"
> package but no success.
>
> Thanx in advance.
>
> Sachin
>
> __________________________________________________
>
>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html
>



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Fri May 19 02:21:54 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Fri 19 May 2006 - 04:10:14 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.