[R] How to find the path or the current file?
ggrothendieck at gmail.com
Tue Mar 24 13:00:06 CET 2009
On Tue, Mar 24, 2009 at 7:16 AM, Marie Sivertsen <mariesivert at gmail.com> wrote:
> Dear useRs,
> I have a collection of source file and some of these call others. The files
> are distribute among a number of directories, and to know how to call some
> other file they need to know what file is currently executed.
> As example, I have a file 'search.R' located in directory 'bin' which needs
> to access the file 'terms.conf' located in the directory 'conf', a sibling
> of 'bin'. I can have somethings like readLines('../conf/terms.conf') in
> search.R, but this work only if search.R is executed from bin, when getwd is
> 'bin'. But when search.R calls from the parent as bin/search.R or any other
> derectory then R complains that it could not find the file
> So my questions is: how can the file search.R, when executied, discover its
> own location and load terms.conf from <location of
> search.R>/../conf/terms.conf? the location of search.R can be unrelated to
> the current directory.
> [[alternative HTML version deleted]]
> R-help at r-project.org mailing list
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help