I've been searching for a while for a way to get the name of the currently executed script. Most answers I've seen were one of:
- Use
commandArgs()
- but this won't work for me because in RStudiocommandArgs()
does not return the filepath - Define the name of the script as the top line and then use that in the rest of the script
I saw one mention of sys.frames()
and found out that I can use sys.frame(1)$ofile
to get the name of the currently executing script. I don't know much about these kinds of functions, so can anyone advise me if that's a bad a idea or when it can fail me?
Thanks