Thursday, 15 August 2013

How to get the file name of the R script currently being executed (for easy automatic email of results)

How to get the file name of the R script currently being executed (for
easy automatic email of results)

I am writing an R script in Rstudio, and I would like some way to get the
name of the file the code is written is. The reason why I want to do this
is I want a piece of code I can stick at the bottom of all my scripts so
that my results are automatically emailed to me using the sendmailR
package.
I'd like my attachment name to have the structure filename_date where
filename is the name of the file being executed and date is the time of
the execution. Is there a way of doing this, or will I have to type out
the name of the file by hand every time I run a new script.
A similar question was asked here, but because the use was different the
workaround solution never provided an answer. I actually don't need the
location, just the filename and I think this is what should make it doable
(but maybe not)
Find location of current .R file

No comments:

Post a Comment