//
you're reading...
R

R: Creating a shortcut to run a gWidgets GUI

I’ve been playing around with using gWidgets on Windows over the last few weeks as a way of creating front ends for various functions and set of functions that I’ve created, so that non R users can have the benefit of these without having to write a single line of code.

The likes of 4Dpiecharts offer some good introductions to various aspects of the tool, but one thing which I struggled to find was a way of creating an icon based way of launching the GUI – i.e. click on an icon on the desktop and have the GUI launch in an application like way.

At first, I assumed that this could be done via a batch file, but found that this didn’t seem to work when the script should display a GUI as the output.

I then came across this very handy stackoverflow post. Although, slightly enigmatic, the method outlined by Greg Snow worked and gave me what I wanted.

1. Create a new folder at a convenient place on your drive.

2. Create a shortcut to RGui.exe or Rterm.exe – these will likely be located in a folder like C:\program files\R\R-version\bin\i386. If the shortcut is to RGui then the full R GUI will be brought up, whilst R term will bring up the console version (I went with this option so that the focus would stay with the GUI).

3. Create an R function called .First which includes the various functions, data, etc. to launch your code.

 .First <- function() {  insert code here } 

4. Ensure that your R session is clean and only contains the functions (particularly .First) and data that you want to launch when you double click the shortcut. Save this workspace (which will be called “.rData”) to the folder that you created in Step 1.

5. Right click on the Shortcut that you created in Step 2 and change the Start In property (under the “Shortcut” tab) to the name of the folder that you created in Step 1.

About these ads

Discussion

8 thoughts on “R: Creating a shortcut to run a gWidgets GUI

  1. VERY interesting.

    Any chance you will add a ZIP file with a folder structure that implements your steps?

    Cool post :)
    Tal

    Posted by Tal Galili | June 18, 2012, 4:55 pm
  2. excellent advice! I’ve been playing around with gWidgets myself and this was one of the items in my to-do list…

    Posted by gufodotto | June 19, 2012, 11:41 am
  3. Man, for some reason when I follow this tutorial, when I double click the Rgui shortcut, it just brings me the regular console (empty). The function is saved to the workplace, but it isn’t loaded automatically when I double click it? Any advice?

    Thanks in advance!

    Posted by Michael | June 28, 2012, 6:22 pm

Trackbacks/Pingbacks

  1. Pingback: Look ma! No typing! Autorunning code on R startup « 4D Pie Charts - July 20, 2012

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog Stats

  • 328,103 hits

Enter your email address to follow this blog and receive notifications of new posts by email.

Join 526 other followers

Follow

Get every new post delivered to your Inbox.

Join 526 other followers

%d bloggers like this: