Hi, there. I am trying to read multiple files into R, but I got following message Error in file(file, "r"): All connections are in use. I clean up memory everytime I read in one file. Do i have to somehow release file connection everytime i read in one?? Thanks. Lei Department of Chemsitry University of Washington Box 351700 Seattle, WA 98195 Phone: 206-616-6882 Fax: 206-685-8665
Prof Brian Ripley
2004-May-04 21:06 UTC
[R] error in file(file, "r"): all connections are in use
On Tue, 4 May 2004, Lei Jiang wrote:> I am trying to read multiple files into R, but I got following message > > Error in file(file, "r"): All connections are in use. > > I clean up memory everytime I read in one file. Do i have to somehow > release file connection everytime i read in one??No, but you do need to release them eventually -- call close(). Your OS will also have a limit on the number of files you can have open at any one time, and it may not be much greater than the number of connections that can be in use (around 50). I cannot imagine needing more than 50 connections open at once, but if you do you can alter the limit and recompile R. -- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595
Vadim Ogranovich
2004-May-04 21:49 UTC
[R] error in file(file, "r"): all connections are in use
If you open a connection within a function it is often a good idea to set an "on.exit" expression that will close the connection. This will be called even if your function terminates via stop(). Here is an example: con <- file("foo") open(con) on.exit(close(con), add=TRUE) HTH, Vadim> -----Original Message----- > From: Lei Jiang [mailto:lj22 at u.washington.edu] > Sent: Tuesday, May 04, 2004 2:02 PM > To: R-help at stat.math.ethz.ch > Subject: [R] error in file(file, "r"): all connections are in use > > > Hi, there. > > I am trying to read multiple files into R, but I got following message > > Error in file(file, "r"): All connections are in use. > > I clean up memory everytime I read in one file. Do i have to > somehow release file connection everytime i read in one?? > > Thanks. > > Lei > > Department of Chemsitry > University of Washington > Box 351700 > Seattle, WA 98195 > Phone: 206-616-6882 > Fax: 206-685-8665 > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://www.stat.math.ethz.ch/mailman/listinfo> /r-help > PLEASE > do read the posting guide! > http://www.R-project.org/posting-guide.html >