如何编写将其源代码复制到文件的R程序?

时间:2015-07-24 17:21:47

标签: r

我正在编写一个R脚本,其内容可能会不时更改。如果我可以插入一个将脚本的当前内容复制到文件的命令,那将非常有用,所以我可以稍后再回过头来查看在该代码运行期间我执行了哪些命令。

我该怎么做?

1 个答案:

答案 0 :(得分:2)

您可以使用教学演示包进行此操作:

    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

相关问题