[R] Issue with R write() function

Jeff Newmiller jdnewm|| @end|ng |rom dcn@d@v|@@c@@u@
Sat Jun 23 23:58:33 CEST 2018


1. This behavior is dictated by the file system (an operating system feature) that is in use. Chances of it changing in R are extremely small.

2. While not clearly documented, this behavior is consistent with the definition of what a "csv" file is. Headers located at other than line 1 are not valid, and the write.csv function cannot insure that multiple invocations will lead to a valid csv file. Since write.csv is just a convenience wrapper around write.table, you can probably accomplish what you are after by giving appropriate parameters to write.table. e.g.

write.table( x=1, file="tmp.csv", sep=",", row.names=FALSE )
write.table( x=2, file="tmp.csv", append=TRUE, sep=",", row.names=FALSE, col.names=FALSE )

It will be up to you to keep the format consistent.


On June 23, 2018 1:23:10 PM PDT, Hamed Ha <hamedhaseli using gmail.com> wrote:
>I
>am recently updated to R 3.5.0 and noticed some weird errors in write()
>function. Further, I noticed that write.csv, write.table and generally
>the
>functions that derive from write() are all weird.
>
>  1. write() function does not accept a path longer than 256 characters
>neither on Windows or Unix. Noticed that a full path can be longer than
>256
>   characters, however, the directory name cannot, at least on windows.
>
>   2. The append parameter does not work at all, just try
>   ​​
>   ​​
>   write.table(x = 1,file =  '
>   tmp
>   ',append = TRUE)
>   ​ or write.csv(x = 1,file =  'tmp',append = TRUE)​
>
>P
>lease can someone report to the developement team?
>
>
>Regards,
>Hamed.
>
>	[[alternative HTML version deleted]]
>
>______________________________________________
>R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
>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.

-- 
Sent from my phone. Please excuse my brevity.




More information about the R-help mailing list