我有一个应该使用 setwd() 更改工作目录的 R 脚本。
我的代码:
setwd(file.path(work_dir, database_dir, study))
我可以在该行应该执行之前暂停我的脚本(使用browser()
)将代码输入控制台没有问题,但是每当从脚本执行该行时,我都会收到错误框,指出“打开文件时出错:该系统找不到指定的文件。” 在调用 setwd 之前,在我的脚本中,我使用file.exists(file.path(work_dir, database_dir,study))
. 我还重新启动了 R studio 并关闭并重新打开了我的所有脚本,以确保这不会导致问题。
有没有人有任何其他建议让我尝试?