[R] Files and Windows/NT

Prof Brian D Ripley ripley at stats.ox.ac.uk
Tue May 25 08:26:00 CEST 1999


On Tue, 25 May 1999, David Scott wrote:

> I am using rw0.63.2.
> 
> I haven't upgraded because we use R for teaching. Students use R at
> home, and we don't want to change them over in midsemester.
> 
> Also we have some additional functions we use, and we need to test them
> before we start to use a new version. Which brings me to my question.
> 
> To help with testing we are preparing a test file which will run through
> all our examples. In the course of this we have run into a problem which I
> think is a Windows limitation which will probably be easily explained by
> Brian or Guido. 
> 
> We have the commands in a file and just source it to run the checks. After

Please don't do that. Use rterm and redirect the input, as in the rw-FAQ
section on running batch files.  The use of source increases the 
memory usage (because of all the delayed commitments), suppresses
autoprinting (as the evaluation is not at the top level) and often
breaks things (ditto).

> we go through a number of scans to read in data sets R stops with the
> message scan can't open file. This I know normally means it can't find it.
> If we restart R and run that bit of code separately there is no problem.
> 
> What I believe is happening is that Windows has a limit on the number of
> files that can be open at any one time. Is that the case?

All OSes have such a limit. But it depends on the version of Windows, and
is unlikely to be biting here. How many files are you opening? I think this
is much more likely to be a resources problem than a lack of file handles.

> Also when scan is used, the file remains open or reserved by R.

scan() explicitly closes the file unless it is a tty, that is no name is
given and you read from the terminal.

> So, is my understanding correct? Is there any way to close a file and
> to keep on reading more files? 

When I create the MASS library I scan (sometimes via read.table) a hundred
or so files in succession and see no problems.  But I do not do this in
source().

>From your initial description, it looks to me as if the clean way to do
this is to put your functions and datasets in a library, and run make
pkgcheck to run all the examples on the help pages.

Brian Ripley

-- 
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 272860 (secr)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list