I have a R script that should change the working directory using setwd().
My code:
setwd(file.path(work_dir, database_dir, study))
I can pause my script just before this line is supposed to execute (using browser()
) enter the code into the console without issue, but whenever the line is executed from the script I get the error box stating that there is an "error while opening file: The system cannot find the file specified." Within my script before calling the setwd, I confirmed that the path exists using file.exists(file.path(work_dir, database_dir,study))
. I also restarted R studio and closed and reopened all of my scripts to make sure that was not causing the problem.
Does anyone have any other suggestions for me to try?