[R] Genuine relative paths with R

Peter Claussen
Wed, 10 Oct 2018 23:29:39 -0000

If I?m following all this correctly, it seems your criticism is that R doesn?t
provide a run-time function that is equivalent to a compile-time macro. You do
realize that __FILE__ is not part of the C programming language - it?s a
predefined variable recognized by the cpp - the C preprocessor program.
Similarly, SAS_EXECFILENAME is a predefined variable that can be recognized by
the SAS macro processor, but has no meaning in the SAS language itself.

So, to go back to your original post:
> 1.  Either create a variable "ScriptPath" in the first lines of
each of my R scripts and run a batch (or shell, etc.) to replace every single
occurrence of "ScriptPath <-" by "ScriptPath <- [Absolute
path of the R script]" in all the R scripts located in the folder (and
possibly subfolders) of the batch file.


This is what a macro processor does. Are you asking for a macro language in R?

Cheers

> On Oct 10, 2018, at 6:11 PM, Olivier GIVAUDAN <olivier_givaudan at
hotmail.com> wrote:
>
> It is not wrong to claim that R currently doesn't have a function
returning the path of the R file where this same function was invoked.