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