J Karon
2013-Dec-13 19:11 UTC
[R] Invalid connection error message when trying to write a file
I get an invalid connection method error message when trying to write an R object from a user-defined function to my hard drive (running Windows 7) using write.csv. I have previously not had this problem with the same user-defined function. The error message is Error in isOpen(file, "w") : invalid connection In addition: Warning message: In if (file == "") file <- stdout() else if (is.character(file)) { : the condition has length > 1 and only the first element will be used Using zz<-file(description="path","w") write.csv( ) close(zz) creates an empty file but yields the same error message when I execute write.csv. -- View this message in context: http://r.789695.n4.nabble.com/Invalid-connection-error-message-when-trying-to-write-a-file-tp4682149.html Sent from the R help mailing list archive at Nabble.com.
Uwe Ligges
2013-Dec-14 17:05 UTC
[R] Invalid connection error message when trying to write a file
On 13.12.2013 20:11, J Karon wrote:> I get an invalid connection method error message when trying to write an R > object from a user-defined function to my hard drive (running Windows 7) > using write.csv. I have previously not had this problem with the same > user-defined function. The error message is > > Error in isOpen(file, "w") : invalid connection > In addition: Warning message: > In if (file == "") file <- stdout() else if (is.character(file)) { : > the condition has length > 1 and only the first element will be used > > Using > zz<-file(description="path","w") > write.csv( ) > close(zz) > > creates an empty file but yields the same error message when I execute > write.csv.Please tell us what you actually did. This works for me: zz <- file(description="path", "w") write.csv(iris, zz) close(zz) Best, Uwe Ligges