Re: [R] search path question

From: Barry Rowlingson <>
Date: Tue, 29 May 2007 18:34:06 +0100

Zhiliang Ma wrote:
> I want to find a function that can simply add
> "C:\inFiles\" into R's search path, so that we I scan a file R will go to
> all the search paths to find it. In matlab, path(path,"C:\inFiles") will do
> this job, I'm just wondering if there is a similar function in R can do this
> job.

Something like this (not extensively tested):

`sscan` <-

   function(name, path=options()$scanpath,...){

     for(p in path){
       ## last resort..


Then do:


  and then:


  will look for /tmp/ first, then if that fails it will do the 'last resort' which is to look in the current directory.

  My worry is that this will bite you one day - if you have two files with the same name, it will get the first one in your scanpath - one day this will not be the one you think it is....

  Note this only works with 'scan' - you'll have to do the same thing for read.table, source, etc etc if you want them to behave with a search path too. Unless there's a lower-level approach. But that really will bite you!


Barry mailing list PLEASE do read the posting guide and provide commented, minimal, self-contained, reproducible code. Received on Tue 29 May 2007 - 17:33:10 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 29 May 2007 - 18:31:17 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.