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

Jason Barnhart jasoncbarnhart at msn.com
Thu May 18 17:55:51 CEST 2006


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


****** End XLS File *******


----- Original Message ----- 
From: "Sachin J" <sachinj.2006 at yahoo.com>
To: <R-help at stat.math.ethz.ch>
Sent: Thursday, May 18, 2006 7:36 AM
Subject: [R] write.csv + appending output (FILE I/O)


> 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 at 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
>




More information about the R-help mailing list