2015-11-25 102 views
4

當我更改工作目錄(例如,從dir1到dir2),然後嘗試使用choose.files()時,第一次選擇.files()運行它將轉到dir1。如果我第二次取消並運行choose.files(),則它會在dir2中打開。我如何獲得choose.files()在最新的工作目錄中打開?爲什麼不在當前工作目錄中打開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 

我想能夠使用此進程從當前工作目錄中選擇一個文件。欣賞任何想法。謝謝!

+1

對於linux/mac上的任何人請注意,'choose.files()'是一個僅限Windows的函數。 – Dason

+0

文檔中「choose.files」的描述:使用Windows文件對話框以交互方式選擇零個或多個文件的列表。所以@Dason是對的。它只適用於windows。 –

回答

2

嘗試增加這個面具到default說法:

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

從幫助?choose.files

如果你想在一個特定的目錄中顯示的文件,給 完全合格的文件在默認參數中使用掩碼(例如「c:\ *。*」)。

+0

當我輸入'choose.files'時,它返回'沒有'choose.files'的文檔。我正在使用Ubuntu。 'choose.files'只能在Windows上使用。 –

+0

你在使用Narendra的操作系統是什麼? –

+0

@我使用的是Ubuntu.I,只是在線查看了文檔。它說'choose.files'只適用於Windows。 –

相關問題