On 03/03/2020 10:47 a.m., Ivan Calandra wrote:
That's what I was about to answer but tried first and it did not work.
Now I tried more and noticed an unexpected behavior:

getwd()
[1] "C:/Users/.../Documents"
file.choose() ## opens in "C:/Users/.../Documents" as expected

setwd("D:/")
getwd()
[1] "D:/"
file.choose() ## unexpectedly, opens in "C:/Users/.../Documents"

setwd("D:/Data")
getwd()
[1] "D:/Data"
file.choose() ## opens in "D:/Data" as expected

Is that normal behavior?


If I recall correctly, the Windows GUI version opens the same directory as the user last selected (i.e. the dialog box remembers the last selection). This was by design, because Windows users often start the GUI with the working directory being the R home directory, and rarely use setwd() to change it.

On Windows, I think you always get that version. On other platforms it may depend on which front end you're using.

Duncan Murdoch

______________________________________________
R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to