我正在写一个R脚本,其内容可以随时更改。如果我能插入一个命令,将脚本的当前内容复制到一个文件中,那将非常有帮助,这样我就可以稍后返回并查看在运行代码期间执行了哪些命令。
我该怎么做?
您可以使用教学演示包:
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()
源