How about this:
search.path <- function(fn, paths = strsplit(Sys.getenv("PATH"), split = ";")[[1]], fsep = "\\") { for(d in paths) { f <- file.path(d, fn, fsep = fsep) if (file.exists(f)) return(f) } return(NULL) } source(search.path("myscript.R")) Shin, Daehyok <sdhyok <at> email.unc.edu> writes: : : Considering replies to my question, typical practices of R users seem: : 1. Creating a special function to source frequently used scripts. : 2. Creating a personal package containing frequently used scripts. : : Both of them needs additional steps to edit the function or to : create/install the package : when a script file is edited or added. My suggestion can save the effort. : In the sense to make R more convenient environment to users, is it trivial? : : Daehyok Shin : : > -----Original Message----- : > From: Roger D. Peng [mailto:rpeng <at> jhsph.edu] : > Sent: Saturday, July 10, 2004 PM 11:14 : > To: sdhyok <at> email.unc.edu : > Cc: Liaw, Andy; R, Help : > Subject: Re: [R] where does R search when source()? : > : > : > In fact, there is an elegant solution, and that is to write a : > package. If this is all for personal use, then writing a package : > can be as simple as creating a few directories, copying the : > script files, and then running R CMD INSTALL. I do this all the : > time when I have multiple projects that use the same code. : > : > -roger : > : : ______________________________________________ : R-help <at> stat.math.ethz.ch mailing list : https://www.stat.math.ethz.ch/mailman/listinfo/r-help : PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html : : ______________________________________________ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html