[R] choose folder interactively

jim holtman jholtman at gmail.com
Wed Nov 28 14:06:42 CET 2012


A simple way is to use 'choose.file' to select a file in the directory
that you want and then use 'dirname' to strip off the file name:

> dirname('a/b/c')
[1] "a/b"



On Wed, Nov 28, 2012 at 7:59 AM, Ivan Calandra
<ivan.calandra at u-bourgogne.fr> wrote:
> Thank you Duncan for your answer
>
> I would like to be able to write an equivalent for MacOS, but I'm not that
> skilled... I don't know how to find how choose.dir() is written. And then,
> I'm even less sure to be able to find the equivalent...
>
> Would you mind giving my some hints?
>
> Thank you in advance
> Ivan
>
> --
> Ivan CALANDRA
> Université de Bourgogne
> UMR CNRS/uB 6282 Biogéosciences
> 6 Boulevard Gabriel
> 21000 Dijon, FRANCE
> +33(0)3.80.39.63.06
> ivan.calandra at u-bourgogne.fr
> http://biogeosciences.u-bourgogne.fr/calandra
>
> Le 28/11/12 13:47, Duncan Murdoch a écrit :
>>
>> On 12-11-28 7:39 AM, Ivan Calandra wrote:
>>>
>>> Dear users,
>>>
>>> I am looking for a function to choose a folder interactively, just like
>>> file.choose() but for a folder.
>>>
>>> I have found tcltk::tk_choose.dir() but R hangs when I try to do
>>> anything and I have to force exit.
>>> I've tried to reinstall tcltk with install.packages(), but "package
>>> ‘tcltk’ is not available (for R version 2.15.2)" even though it's
>>> already installed on my computer (it comes with 'base', doesn't it?).
>>>
>>>   From a Google Search, I have also found choose.dir(), but it looks like
>>> this function doesn't exist anymore since ages.
>>>
>>> Any idea?
>>
>>
>> "choose.dir()" does exist on Windows, so you could switch to that OS, or
>> write your own equivalent for MacOS.
>>
>> Duncan Murdoch
>>
>>
>
> ______________________________________________
> R-help at r-project.org mailing list
> 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.



-- 
Jim Holtman
Data Munger Guru

What is the problem that you are trying to solve?
Tell me what you want to do, not how you want to do it.




More information about the R-help mailing list