How to write an R program that copies source code to a file?

I am writing an R script whose contents may change from time to time. It would be very helpful if I could insert a command that would copy the current contents of the script into a file, so I can come back later and see what commands I executed during this code run.

How can i do this?

+4
source share
1 answer

You can do this with the demo package:

    install.packages("TeachingDemos")
    library(TeachingDemos)

    #Will write to a file in the working directory
    txtStart("captureCode.txt")

    #This comment will not appear in the file, all commands and output will
    Sys.Date() 

    #This command ends writing to the file
    txtStop()

Source

+2
source

Source: https://habr.com/ru/post/1599558/


All Articles