当我更改工作目录(例如,从 dir1 到 dir2)然后尝试使用 choose.files() 时,choose.files() 第一次运行时它会转到 dir1。如果我取消并再次运行 choose.files(),那么它会在 dir2 中打开。我怎样才能让 choose.files() 在最新的工作目录中打开?
(我在 file.choose() 中遇到了一个不同的问题,所以我无法使用该函数作为替代)
下面是一个例子:
getwd() # say this is dir1
setwd(choose.dir()) # here I change the wd to dir2
getwd() # currently set to dir2
choose.files() # this opens in dir1
choose.files() # this time it opens in dir2
我希望能够使用此进程从当前工作目录中选择一个文件。欣赏任何想法。谢谢!
最佳答案
尝试将此掩码添加到 default
参数中:
choose.files(default=paste0(getwd(), "/*.*"))
来自
?choose.files
的帮助:关于r - 为什么选择.files() 不在当前工作目录中打开?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/33924986/