Issue with R write() function

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Issue with R write() function

hamedhm
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]]

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: Issue with R write() function

Jeff Newmiller
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 <[hidden email]> 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]]
>
>______________________________________________
>[hidden email] 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.

______________________________________________
[hidden email] 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.