Skip to content
Prev 179999 / 398513 Next

Set working directory by dragging text file onto R shortcut? [WinXP, unfortunately]

There are a several possibilities using batchfiles whose
home page is at:

http://batchfiles.googlecode.com

When on that home page note that there are different versions of
these utilities for XP and Vista.

There are two utilities that could be used.  Description is
for Vista so for XP you may have to vary it slightly.

1. RguiStart.bat is a batch file that starts R interpreting
its first argument as the folder in which to start R (or if its
an .Rdata file then it interprets it as the .Rdata file to start
R with).  The main reason for its existence is so that you can
place it in your SendTo folder.  On Vista do this:

  copy RguiStart.bat %APPDATA%\Microsoft\Windows\SendTo

Then, on Vista, when you are in Windows Explorer you can right click
on any folder in your user area and choose SendTo.  From the SendTo
menu choose RGuiStart.bat to start up R in that folder.  If you
right click on an .Rdata file rather than a folder then R will
start up with that file loaded (although in that case its probably
easier to just double click the .Rdata file provided you have
file type associations set up -- if you don't then the RguiStart.bat
will provide an alternative).

2. Rgui.bat is a batch file that starts up R.  Just shift right click
a folder in Windows
Explorer and choose Open Command Window Here and then when the command
window opens enter Rgui assuming you have placed Rgui.bat somewhere on
your path.

Note that Rgui.bat and RguiStart.bat are actually the same file just renamed.
When it runs it uses the name by which it was called to determine what to do.
The files have no dependencies and find R by looking in the registry so when
you install a new version of R they continue to work without any change
(because installing a new version of R updates the registry).
On Mon, May 11, 2009 at 6:30 PM, Mark Na <mtb954 at gmail.com> wrote: