[R] confusion about write.csv

Erin Hodgess er|nm@hodge@@ @end|ng |rom gm@||@com
Fri Jun 5 03:34:14 CEST 2020


 Hello!

Hope everyone is doing as well as possible.

I have a question about write.csv.  I thought that the append argument
would permit adding another data frame with the same column names.

Here is my example:

 date1 <- as.Date("2020-03-09")
 wday <- weekdays(date1)
 x1 <- data.frame(date=date1,day=wday,lev=1:5,y=rnorm(5))
 x1
        date    day lev           y
1 2020-03-09 Monday   1 -0.09543049
2 2020-03-09 Monday   2  0.53943428
3 2020-03-09 Monday   3 -0.79224851
4 2020-03-09 Monday   4  0.68168147
5 2020-03-09 Monday   5 -1.02902897
 write.csv(file="test1.csv",x1,row.names=FALSE)
 date1 <- date1 + 1
 wday <- weekdays(date1)
 x2 <- data.frame(date=date1,day=wday,lev=1:5,y=rnorm(5))
 x2
        date     day lev          y
1 2020-03-10 Tuesday   1 -0.6648301
2 2020-03-10 Tuesday   2 -0.1137580
3 2020-03-10 Tuesday   3  1.6532675
4 2020-03-10 Tuesday   4 -0.5845293
5 2020-03-10 Tuesday   5  0.2849392
 write.csv(file="test1.csv",x2,row.names=FALSE,append=TRUE)
Warning message:
In write.csv(file = "test1.csv", x2, row.names = FALSE, append = TRUE) :
  attempt to set 'append' ignored

The values from x2 appear in the test1.csv file.

What am I missing, please?

Thanks,
Erin


Erin Hodgess, PhD
mailto: erinm.hodgess using gmail.com

	[[alternative HTML version deleted]]



More information about the R-help mailing list