Re: [R] search path question

From: Barry Rowlingson <>
Date: Wed, 30 May 2007 10:18:09 +0100

Prof Brian Ripley wrote:

> 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).

  I'm not sure exactly what you mean by a 'search_file() connection wrapper', but I have realised that its probably a better idea to write a function that checks a search path for a file and then returns that file:

search_file =
function(name,path=options()$scanpath,...){ for(p in path){



  Then you can use that in any filename-using function:


  > search_file("passwd")
  [1] "/etc/passwd"

  > passwd = read.table(search_file("passwd"),sep=":")   > record = scan(search_file("passwd"),what='')[1]

Barry mailing list PLEASE do read the posting guide and provide commented, minimal, self-contained, reproducible code. Received on Wed 30 May 2007 - 09:19:25 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 Wed 30 May 2007 - 12:31:40 GMT.

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