R: Creating a shortcut to run a gWidgets GUI

[This article was first published on Drunks&Lampposts » R, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

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.


To leave a comment for the author, please follow the link and comment on their blog: Drunks&Lampposts » R.

R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)