On Feb 8, 2012, at 2:29 PM, Ron Michael wrote:

Okay, so I understood that appending can only happen row-wise. Therefore I tried with following code:

write.csv(matrix(1:5, 1), "dat.csv")
write.csv(matrix(1:5, 1), "dat.csv", append = TRUE)
Warning message:
In write.csv(matrix(1:5, 1), "dat.csv", append = TRUE) :
  attempt to set 'append' ignored

It is destroying my previous file. Where I have done wrong?

Failed to read the help page. `write.csv` has some of its setting hard coded and will prevent you from changing them. "append" happened to be in that list.

Here's the code.... it's right there for all to see:

    Call <- match.call(expand.dots = TRUE)
for (argname in c("append", "col.names", "sep", "dec", "qmethod")) if (!is.null(Call[[argname]]))
        warning(gettextf("attempt to set '%s' ignored", argname),
            domain = NA)
--

David.

Thanks,


----- Original Message -----
From: Uwe Ligges <lig...@statistik.tu-dortmund.de>
To: Ron Michael <ron_michae...@yahoo.com>
Cc: "r-help@r-project.org" <r-help@r-project.org>
Sent: Thursday, 9 February 2012 1:07 AM
Subject: Re: [R] Wriritng to a CSV file



On 08.02.2012 20:14, Ron Michael wrote:
Dear all, let say I want to write a vector to a CSV file. So I can have following syntax:

write.csv(rnorm(10), "dat.csv")

Now I want to add one more column into that existing file. If I use the same code then existing file will be destroyed. Is there any functionality to add without destroying the existing file? I have tries with 'append = TRUE' however it is not working!

Any suggestion will be highly appreciated.

Since these text files are written line by line, you cannot add a column
afterwards, you can just append rows.

Hence read the first column and write a two column data.frame afterwards.

Uwe Ligges


______________________________________________
R-help@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@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.

David Winsemius, MD
West Hartford, CT

______________________________________________
R-help@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.

Reply via email to