[R-sig-Geo] Determine the location of the actual R-file
Paul Hiemstra
p.hiemstra at geo.uu.nl
Fri Oct 2 10:23:49 CEST 2009
Hi Nils,
Getting the current working directory is done using getwd().
I have some comments inline below:
Breitbach, Nils wrote:
> Dear community,
>
> this time my question has something to do with with spatial context but not in the sense we discuss it usually here. I tried to find out if it is possible to ask R for the location (path) of the R-file from which I send the code.
What do you mean by "send the code". You mean that you want to use
source() to load some functions? But obviously you can't source() a file
if you don't know where it is located. And a better alternative to
source might be writing an R-package. I'm confused...
> What I want to ensure is, that the R code works, no matter where I move the folder with all the necesssary files to. There are some ways to code the location relative to an environment variable (like R.home) but I need the location independent of the directory where R is installed since this is not equal on every users' maschine.
>
My suggestion would be to wrap the code in an R-package. A user can
install the R-package and load it easily using library() and you don't
have to worry about getting the path to the code.
> Is there a way to ask R for the path of the r-file from which the line is sent?
>
Probably if you use an R-package construction this is not necessary.
cheers,
Paul
> I hope that you have some ideas for me ...
> Cheers,
>
> Nils
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>
--
Drs. Paul Hiemstra
Department of Physical Geography
Faculty of Geosciences
University of Utrecht
Heidelberglaan 2
P.O. Box 80.115
3508 TC Utrecht
Phone: +3130 274 3113 Mon-Tue
Phone: +3130 253 5773 Wed-Fri
http://intamap.geo.uu.nl/~paul
More information about the R-sig-Geo
mailing list