RE: [R] where does R search when source()?

From: Shin, Daehyok <sdhyok_at_email.unc.edu>
Date: Sun 11 Jul 2004 - 12:40:27 EST


To my knowledge, it is a common practice for users to archive some script files in other directories than current working directory, when the script files are frequently used in many cases. So, it is somewhat surprising to me there is no elegant solution to set up default search paths in R.

Here is my suggestion.
According to the setup of Python (http://docs.python.org/tut/node8.html), when source() is called,

  1. Search current working directory.
  2. If not found, search the directories specified by the environment variable RPATH.

I think this change will help users to manage script files more easily. What do you think of it?

Daehyok Shin

> -----Original Message-----
> From: Liaw, Andy [mailto:andy_liaw@merck.com]
> Sent: Saturday, July 10, 2004 PM 10:07
> To: 'sdhyok@email.unc.edu'; R, Help
> Subject: RE: [R] where does R search when source()?
>
>
> Not really. The best I can come up with is something like:
>
> runScript <- function(script, dir="", ...) source(file.path(dir, script,
> ...)
> scriptdir <- "/path/to/scripts"
>
> runScript(scriptdir, "myScript.R")
>
> Andy
>
> > From: Shin, Daehyok
> >
> > The reason I asked is to separate script files from data files.
> > Usually, I am working in the directory containing data files, but some
> > script files are in other shared directories. In the case, is
> > there any way
> > to access the script files conveniently without specifying
> > its absolute
> > path? In other word, any way to set up default search paths for script
> > files?
> >
> > Daehyok Shin (Peter)
> >
> > >
> > > The former. No documentation says otherwise, so why would you
> > > think that it
> > > might search somewhere else?
> > >
> > > Andy
> > >
> > >
> > > ------------------------------------------------------------------
> > > ------------
> > > Notice: This e-mail message, together with any attachments,
> > > contains information of Merck & Co., Inc. (One Merck Drive,
> > > Whitehouse Station, New Jersey, USA 08889), and/or its affiliates
> > > (which may be known outside the United States as Merck Frosst,
> > > Merck Sharp & Dohme or MSD and in Japan, as Banyu) that may be
> > > confidential, proprietary copyrighted and/or legally privileged.
> > > It is intended solely for the use of the individual or entity
> > > named on this message. If you are not the intended recipient,
> > > and have received this message in error, please notify us
> > > immediately by reply e-mail and then delete it from your system.
> > > ------------------------------------------------------------------
> > > ------------
> > >
> >
> >
> >
>
>
> ------------------------------------------------------------------
> ------------
> Notice: This e-mail message, together with any attachments,
> contains information of Merck & Co., Inc. (One Merck Drive,
> Whitehouse Station, New Jersey, USA 08889), and/or its affiliates
> (which may be known outside the United States as Merck Frosst,
> Merck Sharp & Dohme or MSD and in Japan, as Banyu) that may be
> confidential, proprietary copyrighted and/or legally privileged.
> It is intended solely for the use of the individual or entity
> named on this message. If you are not the intended recipient,
> and have received this message in error, please notify us
> immediately by reply e-mail and then delete it from your system.
> ------------------------------------------------------------------
> ------------
>



R-help@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 Received on Sun Jul 11 12:48:36 2004

This archive was generated by hypermail 2.1.8 : Fri 18 Mar 2005 - 02:35:31 EST