I'm writing an R script whose contents can change from time to time. It would be really helpful if I could insert a command that would copy the current contents of the script to a file, so I can go back later and see exactly what commands I executed during that run of the code.
How can I do this?
system(sprintf("cp my_script.R my_script_%s.R", format(Sys.time(), '%Y_%m_%d_%H_%m')))make sure you save the script and thensourceit. this line will make a copy of your script and rename it with the current date/time