[R] How to start R in mac with the current directory as the current working directory?

Steve Lianoglou mailinglist.honeypot at gmail.com
Thu Oct 8 17:57:30 CEST 2009


Hi Peng,

On Oct 8, 2009, at 11:21 AM, Peng Yu wrote:

> Hi,
>
> I installed R on mac (see below). When I start it from a terminal by
> the following command, the current working directory is always '~' no
> matter where my current directory is in the terminal. I'm wondering if
> there is a way to make the gui R on mac inherent the current directory
> from the terminal.
>
> /Applications/R.app/Contents/MacOS/R

Look in the R > Preferences >Startup dialog under the "Initial working  
directory" section. You'll see you can run this from the command line  
in order to open R.app within a given directory:

$ open -a R.app <dir-or-file>

So, to open in the current directory, just type:

$ open -a R.app .

You can make an alias for this and set it in your .bash_profile in  
order to make your life easier, maybe:

alias r="open -a R.app ."

Small r so it doesn't interfere with /usr/bin/R

Hope that helps,

-steve

--
Steve Lianoglou
Graduate Student: Computational Systems Biology
   |  Memorial Sloan-Kettering Cancer Center
   |  Weill Medical College of Cornell University
Contact Info: http://cbio.mskcc.org/~lianos/contact




More information about the R-help mailing list