R可执行文件在写入一个csv后停止

R可执行文件在写入一个csv后停止,r,windows,R,Windows,我使用本教程制作了一个Rexec文件: 我已经用一个文件制作了一个,当我打开Rstudio并运行它时,它会一直运行。但是,我创建的Rexec文件运行到第一个csv,然后停止。有没有办法将Rexec文件保持为一个文件并运行所有CSV,或者它必须成为多个文件 存在于一个文件中的相关代码如下: #Measure the time taken start.time <- Sys.time() # Load functions in other R files source("R/Fun

我使用本教程制作了一个Rexec文件:

我已经用一个文件制作了一个,当我打开Rstudio并运行它时,它会一直运行。但是,我创建的Rexec文件运行到第一个csv,然后停止。有没有办法将Rexec文件保持为一个文件并运行所有CSV,或者它必须成为多个文件

存在于一个文件中的相关代码如下:

    #Measure the time taken
start.time <- Sys.time()

# Load functions in other R files
source("R/Functions.R")
source("R/Negatives Check.R")
source("R/Control Totals.R")
source("R/Validations.R")

# Load Packages
load_packages()

files = load_TZP()
files2 = load_TZP_stacked()

# Negatives Check---------------------------------------------------------------
write_csv(cbind(Name = names(files), create_output()), 
          paste0("Final CSV/Negatives Check ", gsub(":", ".", Sys.time()), ".csv"))
#测量所用的时间

start.time您的工作目录如何(第一个用于RStudio,第二个用于Rexec)?它们是一样的吗

也许,您需要更改Rexec中的工作目录

# Returns an absolute filepath of current working directory of the R process
getwd()

# setwd is used to set the working directory to dir
setwd("C:/Users/User/Documents") # for example

谢谢,阿卡迪,这解决了问题。原始文件位于R项目中,该项目具有灵活的工作目录,具体取决于您将其放置的位置。我对你的评论投了赞成票,但没有显示,因为我没有声誉。你可以接受我的回答。
# Returns an absolute filepath of current working directory of the R process
getwd()

# setwd is used to set the working directory to dir
setwd("C:/Users/User/Documents") # for example