[R] File opening error after 1020 files opened

jonathan_li@agilent.com jonathan_li at agilent.com
Fri Feb 28 05:10:03 CET 2003


I experimented with openning just one file repeatedly.

# R
library(pixmap)
filename <- dir("mydir", full=T)[1]
for(i in 2000){ print(i); tmp <- read.pnm(filename); }

The file open failed at when i=1021. So the difference in when file openning
fails is due to the difference in system, not to the fact that I am openning
different files each time.

Thanks,
Jonathan



-----Original Message-----
From: Henrik Bengtsson [mailto:hb at maths.lth.se]
Sent: Thursday, February 27, 2003 4:53 PM
To: 'Jonathan Q. Li'; r-help at stat.math.ethz.ch
Subject: RE: [R] File opening error after 1020 files opened


Reconformed on R v1.6.2 (no patch) on WinXP Pro. Here is my
troubleshooting. Using the following files

-rwx------+   1 hb       None        29943 Jun 30  2002 hb.ppm
-rwx------+   1 hb       None         2049 Jul 20  2002 logosm-gray.pgm
-rwx------+   1 hb       None          379 Jul 20  2002 logosm-mono.pbm
-rwx------+   1 hb       None         3682 Feb  2  1998 logosm.jpg
-rwx------+   1 hb       None         5924 Jun 29  2002 logosm.ppm

# R --vanilla
library(pixmap)

# The following fails to read the file at try 509:
for( i in 1:2000 ) { print(i); x <- read.pnm("logosm.ppm"); }

# The following fails to read the file at try 509:
for( i in 1:2000 ) { print(i); x <- read.pnm("logosm-mono.pbm"); }

# The following fails to read the file at try 509:
for( i in 1:2000 ) { print(i); x <- read.pnm("logosm-gray.pgm"); }

# The following fails to read the file at try 509:
for( i in 1:2000 ) { print(i); x <- read.pnm("hb.ppm"); }

Note that I have to restart R between each file; the problem is not just
locking one file, but it messes up the I/O for all files. I get the same
result over and over again after restarting R and it does not seem like
the filesize matters. Most I/O seems to fails. My dir() and file.show()
still works though. Can not save workspace when quiting R etc. Trying to
delete "logosm.ppm" using WinXP Explorer won't work - the file is
locked.

> R.version
         _
platform i386-pc-mingw32
arch     i386
os       mingw32
system   i386, mingw32
status
major    1
minor    6.2
year     2003
month    01
day      10
language R

Cheers

Henrik Bengtsson

> -----Original Message-----
> From: r-help-admin at stat.math.ethz.ch 
> [mailto:r-help-admin at stat.math.ethz.ch] On Behalf Of Jonathan Q. Li
> Sent: den 28 februari 2003 10:55
> To: r-help at stat.math.ethz.ch
> Subject: [R] File opening error after 1020 files opened
> 
> 
> Hi,
> 
> I am trying to use "read.pnm" from the package "pixmap" to read more 
> than 10 thousand image files in "mydir".
> 
>  > file.list <- dir( "mydir", full=T)
>  > for( i in 1:length(file.list) ) {
>     print(i)
>     x <- read.pnm(file.list[i])
> }
> 
> In the beginning it was fine. But after reading 1020 images 
> or so, the 
> read.pnm function
> seems to crash on me:
> 
> [1] 1017
> [1] 1018
> [1] 1019
> [1] 1020
> Error in open.connection(con, open = "rb") :
>         unable to open connection
> In addition: Warning message:
> cannot open file `/mydir/myfile1020.ppm'
> 
> Then the R environment seems to crash too because I can't 
> read any other 
> files anymore. Neither can I use function "dir".
> 
> dir("mydir")
> character(0)
> Warning message:
> list.files: "mydir" is not a readable directory
> 
> I quit R and close all other applications and come back. The 
> problem is 
> easily repeated.
> THe following is my system information. The linux version is 
> Redhat 8.0.
> 
>  > R.version
>          _
> platform i686-pc-linux-gnu
> arch     i686
> os       linux-gnu
> system   i686, linux-gnu
> status
> major    1
> minor    6.1
> year     2002
> month    11
> day      01
> language R
> 
> 
> Your help is highly appreciated!
> Best Regards,
> Jonathan
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list 
> http://www.stat.math.ethz.ch/mailman/listinfo/> r-help




More information about the R-help mailing list