[R] Invalid connection error message when trying to write a file

Uwe Ligges ligges at statistik.tu-dortmund.de
Sat Dec 14 18:05:46 CET 2013



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



More information about the R-help mailing list