【问题标题】:Why doesn't choose.files() open in the current working directory?为什么没有在当前工作目录中打开choose.files()?
【发布时间】:2016-02-28 17:50:36
【问题描述】:

当我更改工作目录(例如,从 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

我希望能够使用此进程从当前工作目录中选择一个文件。欣赏任何想法。谢谢!

【问题讨论】:

  • 对于 linux/mac 上的任何人,请注意 choose.files() 是一个仅限 Windows 的函数。
  • 文档中choose.files 的描述:使用 Windows 文件对话框以交互方式选择零个或多个文件的列表。所以@Dason 是对的。它仅适用于 Windows。

标签: r filechooser


【解决方案1】:

尝试将此掩码添加到default 参数:

choose.files(default=paste0(getwd(), "/*.*")) 

来自?choose.files的帮助:

如果您想显示特定目录中的文件,请给出 默认参数中的完全限定文件掩码(例如,“c:\*.*”)。

【讨论】:

  • 当我输入 ?choose.files 时它返回 No documentation for ‘choose.files’。我正在使用 Ubuntu。 choose.files 仅适用于 Windows。
  • 你在使用 Narendra 什么操作系统?
  • @我正在使用 Ubuntu。我刚刚在线查看了文档。它说choose.files 仅适用于 Windows。
猜你喜欢
  • 1970-01-01
  • 2012-05-17
  • 2012-02-23
  • 2011-09-18
  • 2018-01-17
  • 2019-09-21
  • 1970-01-01
相关资源
最近更新 更多