我有一个脚本,我想暂停以允许外部错误检查。在某一时刻,脚本会写出一个.csv文件,我需要在外部手动检查,然后在继续之前重新导入。有没有办法告诉R在write.cv
命令之后暂停脚本?
write.csv(x,"file.csv", row.names = FALSE) #export raw .csv file
##### pause to manually check for and correct errors ####
y <- read.csv("file.csv") #import corrected "file.csv"
答案 0 :(得分:2)
您可以使用readline()
功能进行交互式输入。您的代码段可能如下所示:
write.csv(x,"file.csv", row.names = FALSE) #export raw .csv file
cat("Output written to file \"file.csv\".\n")
readline("Please hit \"enter\" to continue.") #script paused
y <- read.csv("file.csv") #import corrected "file.csv"
希望这有帮助。