[R] file.choose()

Ivan Calandra c@|@ndr@ @end|ng |rom rgzm@de
Tue Mar 3 17:29:48 CET 2020


Thank you Duncan.

I tried that through RStudio 1.2.5019 with R 3.6.2 on Win10.

And what I did not mention is that I always cancelled the file.choose()
actions, meaning I did not navigate to another folder.
This does not quite fit what you said, but I might have misunderstood
you, or RStudio overrides this behavior.

I still find it strange that my second and third examples behave
differently.

Ivan

--
Dr. Ivan Calandra
TraCEr, laboratory for Traceology and Controlled Experiments
MONREPOS Archaeological Research Centre and
Museum for Human Behavioural Evolution
Schloss Monrepos
56567 Neuwied, Germany
+49 (0) 2631 9772-243
https://www.researchgate.net/profile/Ivan_Calandra

On 03/03/2020 17:26, Duncan Murdoch wrote:
> 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
>
>



More information about the R-help mailing list