[R] Checking on closed file connections

Jim Nemesh nemesh at broad.mit.edu
Tue Jul 21 23:03:31 CEST 2009


Hi!  I'm wondering if there's a smart way around this:

fileName= (some valid file on your system)

 > 	fileCon=file(fileName, open="rt")
 > 	l<-readLines (fileCon, n= 1)
 >
 > isOpen(fileCon)
[1] TRUE
 > 	close(fileCon)
 > isOpen(fileCon)
Error in isOpen(fileCon) : invalid connection

How do you test for a file being closed if isOpen gives you an error  
message?

Thanks!

-Jim




More information about the R-help mailing list