Determine path of the executing script

前端 未结 28 3003
再見小時候
再見小時候 2020-11-22 08:01

I have a script called foo.R that includes another script other.R, which is in the same directory:

#!/usr/bin/env Rscript
message(\         


        
28条回答
  •  深忆病人
    2020-11-22 08:33

    99% of the cases you might simply use:

    sys.calls()[[1]] [[2]]
    

    It will not work for crazy calls where the script is not the first argument, i.e., source(some args, file="myscript"). Use @hadley's in these fancy cases.

提交回复
热议问题