Orange Forum • View topic - Use RStudio to edit Orange widget R scripts

Use RStudio to edit Orange widget R scripts

General discussions about Orange and with Orange connected things (data mining, machine learning, bioinformatics...).

Use RStudio to edit Orange widget R scripts

Postby merlinson » Mon Mar 03, 2014 1:06

http://www.mediafire.com/download/i986sff2q3tc1ba/callRStudio.py

Hello all,

I have tried to put sufficient install details into the python file to make it easy to get started. This python widget script saves in_data to a tab file, then calls RStudio. The R startup file, .Rprofile, reads in_data into R so RStudio starts up with in_data pre-loaded. If out_data is defined in the R script, it is saved to a tab file in the .Last function in .Rprofile when R exits. Then python reads the out_data tab file to apply out_data to the widget output. Alternately, instead of calling RStudio, the R command line in batch mode can be used. This script needs a new RStudio project to be created so that it has a unique directory to put the custom .Rprofile file in as well as to make a place for the Orange widget R scripts.

I hope this script is generic enough that Windows and Mac versions can be done without too much pain. My system is xubuntu 13.10. In addition to the usual pathname edits, the RStudio and R command names need to be looked at.

Although the script works well for me, the worst drawback of this script must be the use of tab files to exchange the data. To help with this, I have added a ramdisk to my system. It's the tradeoff between slow hard drive and fast ramdrive that uses valuable memory. I'm in search of ideas for a smarter way to do this and I am looking at the RScript widget code, but I'm still too much of a novice in Orange. The widget plotting worked but I couldn't get the output to propagate with the usual "out_data <- in_data".

My motivation for this script is the idea that doing serious programming requires a full-featured IDE. I have been looking for an R-compatible data mining program that has a powerful editor or the ability to connect to one without a bunch of manual boilerplate, but hadn't found it(in the freeware world). Props to KNIME for their effort with their R GUI though. But in my opinion, making one's own full-featured R GUI is too much like trying to reinvent the wheel. Effort should also be given to seamlessly connecting to a powerful external IDE. Programmers are much more productive using the tools that they are familiar with and choose for themselves, which should be reasonably well connected to the working environment. Orange was down the list for evaluation because the other DM programs had more information about how to use them with R. But I found them less flexible to modify. With a ramdisk, the benefit of having RStudio available outweighs the memory drawback of this script for me since I'm not close to having big data issues. With python, flexible Orange, and RStudio, the strong R editing environment puts Orange a level above the others. Thus, I had to share this script. Perhaps someone might find this idea interesting enough to take further. Of course, this file is very simple and lacks features, most importantly exposing the appropriate other in_* and out_* structures to R. A GUI wouldn't hurt either. Any info, suggestions and warnings are appreciated, considering my present level of knowledge about Orange. Am I going to end up reinventing the wheel too? Would something like this be an appropriate added feature for the RScript widget?

Best regards,
Merlinson

Re: Use RStudio to edit Orange widget R scripts

Postby merlinson » Thu Mar 06, 2014 0:22

http://www.mediafire.com/download/mjnzbbi72eimglh/OWRStudio.py

http://www.mediafire.com/download/p0fjl2piy32xp0u/R.svg

Hello all,

I'm starting to learn a little more about Orange and so made an OWRStudio.py widget with a little GUI and an icon to make the callRStudio.py file in my previous post more useable and friendly. The same matching .Rprofile file as before must be installed in an RStudio project, so the new widget requires that install first. The values for projectPath, tempDataPath, and the file names are still set to my values in OWRStudio.py, so they need to be changed like before to match your .Rprofile file values. To install this widget, I put the OWRStudio.py file in the Demo/orangedemo directory and the R.svg file in the icons directory below that. If you don't have an orangedemo directory, go to one of the orange.biolab.si web pages and click on "Widgets" under the "Extending" Column at the bottom. The orangedemo directory gets created in the "Getting Started" link on the Orange Widgets Development page, so working through that first page is enough. Following the tutorial, use the 'python setup.py develop' command in the Demo directory to install the new RStudio widget into the Demo widget folder in Orange. Everything seems to work, but it needs more testing. Thanks to Miha Stajdohar whose python widget code I copied and modified.

Now that I am learning some of the great features of Orange I am more impressed than ever. The GUI system is unique and much more powerful, integrated, and easier to use than what I found when I dug into those other DM programs. It really puts them to shame. Those programs promised more than they delivered for me. Then along came Orange and blew me away.

Best regards,
Merlinson


Return to General Discussions



cron