I am using
RStudio 2023.06.1+524 "Mountain Hydrangea" Release (547dcf861cac0253a8abb52c135e44e02ba407a1, 2023-07-07) for windows
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) RStudio/2023.06.1+524 Chrome/110.0.5481.208 Electron/23.3.0 Safari/537.36
with R
R version 4.3.1 (2023-06-16 ucrt) -- "Beagle Scouts"
Copyright (C) 2023 The R Foundation for Statistical Computing
Platform: x86_64-w64-mingw32/x64 (64-bit)
When I attempt to use choose.dir() in the console or a script in RStudio IDE, I get NA. If I do it in the R gui using the same R install, it works as expected.
choose.dir()
[1] NA
I know, install new version of the IDE. Except I can't because I don't have admin privileges. Is that my only fix?
I would like to share my findings, in case they can help identifying the source of the problem.
I am using the latest version of RStudio (just downloaded it), on Windows 10:
RStudio 2023.06.2+561 "Mountain Hydrangea" Release (de44a3118f7963972e24a78b7a1ad48b4be8a217, 2023-08-25) for windows
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) RStudio/2023.06.2+561 Chrome/110.0.5481.208 Electron/23.3.0 Safari/537.36
Also with R 4.3.1.
I confirmed that, when I started RStudio and typed choose.dir() in the console, no dialog box and got NA immediately. This happened again and again if I typed choose.dir() several times.
However, interestingly, if I typed choose.files(), it works, with a dialog box. After the call to choose.files(), choose.dir() will work in the same session, with the dialog box for selecting a folder. However, the problem occurred again when I quitted RStudio and started it again. (In case it is relevant: I did not save the workspace.)
I am happy to know it is not just me or my system (sorry). I too found that choose.files() works as expected AND after calling it and selecting a file, choose,dir() works.
Thanks for the information. Then it is not an RStudio issue, but an R issue, or, specifically, an Rterm issue. Based on the GitHub issue discussion, I tried and confirmed the same problem also occurred in VS Code running Rterm.
If you really need to use choose.dir() in the console (Rterm), a not-so-nice workaround is to call choose.files() first. Once you have called it, then in this session of R, choose.dir() will work.