Actually, it does

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

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@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,                  [EMAIL PROTECTED]
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

______________________________________________
R-help@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.

Reply via email to