[R] Genuine relative paths with R
d@kot@judo @end|ng |rom m@c@com
Thu Oct 11 01:29:39 CEST 2018
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?
> On Oct 10, 2018, at 6:11 PM, Olivier GIVAUDAN <olivier_givaudan using 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.
> 'getwd()' is indeed not equivalent to VBA 'Application.ThisWorkbook.Path' or C macro '__FILE__' or SAS %sysget(SAS_EXECFILENAME), etc.
[[alternative HTML version deleted]]
More information about the R-help