How do I determine the file name of the currently opened R script in R?
2 Example scenarios where this would be helpful:
Saving a current script with a new slightly different name each time an adjustment is made.
My filename is too long, so I cannot read the entire script file name in the window header or in the device menu.
I'll frame the rest of the question on #2 b/c that's my current problem...
- My scripts are saved with date/times at the end, so I need to see the end of the file name in order to tell which file I'm looking at.
The directory path is irrelevant to me because all my files are saved in the same directory.
- I just need to know the full name of the specific script I have opened.
This question does NOT seem to have any solutions that answer my question as I do not want to source any additional files.
- Ex:
commandArgs()
does not provide any relevant info for me
Also, the solution mentioned here did not work either.
system("locate fileName.R")
Warning message:
running command 'locate fileName.R' had status 127
Update: I'm using Rgui not RStudio.
Please help!