[R] search path question

Prof Brian Ripley ripley at stats.ox.ac.uk
Tue May 29 20:36:38 CEST 2007

Actually, it does

     if (is.character(file))
         if (file == "")
             file <- stdin()
         else {
             file <- file(file, "r")

so all the searching is done in the file() connection.

You could do this via a search_file() connection wrapper, but there is a 
problem with ensuring connections get closed (which on.exit does here).

On Tue, 29 May 2007, Barry Rowlingson wrote:

> Zhiliang Ma wrote:
>> Thanks, Barry.
>> In fact, I have a function just like yours, and I'm looking for a simple
>> alternative function, which is like "path" in Matlab.
>  Dont think it can be done - if you look at the code for 'scan', it
> disappears off into internal() calls to do the business of finding and
> reading a file, so you're going to have trouble changing its behaviour
> in R. You'd have to patch R's C source to implement a search path.
> Barry
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.

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

More information about the R-help mailing list