1 / 25

An Introduction to GUI Development using R

An Introduction to GUI Development using R. Overview. Introduction R Interfaces GUIs for programming Programming for GUIs GUIs for teaching how to program GUI task-oriented applications gWidgets package Integrating R into other applications GUI deployment.

emile
Download Presentation

An Introduction to GUI Development using R

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. An Introduction to GUI Development using R

  2. Overview Introduction R Interfaces GUIs for programming Programming for GUIs GUIs for teaching how to program GUI task-oriented applications gWidgets package Integrating R into other applications GUI deployment

  3. IntroductionR Interfaces/Console alternatives RStudio Programmed in C++ and GTK+ JGR Java Revolution R Productivity Environment (RPE) MS Visual Studio Red-R (Open Source visual programming for R SciViews (extends Komodo edit)

  4. GUIs for Programming (code editors) R internal editor (on Mac!) Emacs + ESS Eclipse + StatET Gvim/Vim-R Notepad++ / NppToR WinEdt/RWniEdt ($30!!!) Tinn-R (MS Windows only) jEdit (doesn't pass code to R)

  5. GUIs to learn programming R Commander (Rcmdr package) Satistical analysis functions RKWard (Linux only)

  6. Poll from KDnuggets.com (data miners!)

  7. GUI Programming using R gWidgets package written by J. Verzani “gWidgets provides a toolkit-independent API for building interactive GUIs.” At least one of gWidgetstcltk, gWidgetsRGtk2, gWidgetsQt (on R-Forge only) and qWidgetsrJava needs to be installed.” i.e. GUI toolkits must be installed (except Tcltk, pre-installed, default) the user can switch between GUI toolkits with relative ease and can write code in a toolkit independent way Well, not quite

  8. GTK+ toolkit www.gtk.org

  9. gWidgetsfunctions

  10. GUI contruction using gWidgets Use containers (in ggroup, gwindow, gnotebook functions) to nest widgets Handlers i.e. event handling, define the executed operation Handlers can be added after the GUI is created e.g. addHandlerClicked(…) Drag-and-drop is also featured in gWidgets Demo.... library(gWidgets) options("guiToolkit"="RGtk2") win <- gwindow("Hello World, ad nauseum", visible=TRUE) group <- ggroup(horizontal = FALSE, container=win) obj <- gbutton("Hello...",container=group, handler = function(h,...) gmessage("world")) obj <- glabel("Hello...", container =group,handler = function(h,...) gmessage("world")) obj <- gcombobox(c("Hello","world"), container=group) obj <- gedit("Hello world", container=group) obj <- gtext("Hello world", container=group, font.attr=list(style="bold"))

  11. Sample Problem • Survey conducted to see changes in HIV and non-HIV services in sub-Saharan Africa • Conducted across health centres & hospitals, also individual health-worker data, in several sub-saharan Africa countries • Relatively small questionnaire resulting in 800 variables! • Variables names themselves are not very useful • e.g. “Q001”. Great scope for programming error • Variable labels (the actual questions) contain the information on what is collected • With the concept of variable names dropped, an interactive GUI might work better with variable labels than programming!

  12. Solution • Create new sets of labels • which work as indexes • These can be used to filter, manage and analyze data - Restructuring of data not required • Begin with a search & replace dialogue screen • How would you design it (so that it would be a better option than just using grep or regexpr)? • Demo...

  13. Deducer “An intuitive, cross-platform graphical data analysis system” Deducer is based upon rJava and provides access to the Java Swing Network

  14. gWidgets versus Deducer Deducer has a slightly lower level library, but more flexible and compatible with JGR Deducer requires you to explicitly specify positions of widgets, and is a little more verbose when you come to add event handling logic Visit www.r-bloggers.com for a discussion

  15. Other R GUI packages and tools (which I know little about!) PBS (Pacific Biological Station) packages Rattle (data mining GUI) Brodgar (used for class-room teaching etc.) pmg (poor man’s GUI, similar to Rcmdr)

  16. Current List of Packages with tools for GUI development or utilize a programmed GUI* *as of January 2013

  17. Considerations in GUI development & deployment • Which Widget library? • GTK+, Java, Qt? • Program the UI or use a UI designer? • e.g. QtDesigner • Choice of software for GUI deployment? • R (gWidgets package etc.) • Python (wxPython, PyQt, PyQt4 libraries) • R/Python integration (call R using Rpy, Rpy2) • Sage (www.sagemath.org)? • Sage uses existing open-source libraries wherever they exist! • See sagemath.org, writen in Python & Cython, not supported by MS Windows

  18. Web-applications • rApache project (www.rapache.net) • Embed R in the Apache web server • Rook package • Provides an interface to build web-applications with rApache • gWidgetsWWW • It’s independent of gWidgets! • Use JavaScript libraries, rapache • Shiny in Rstudio!!!

  19. Documentation • Lots of material on the web • Journal of Statistical Software (Vol. 49) • Special issue of R on GUIs • Lawrence and Verzani book (2012)  • gWidgets package vignette

  20. Final comments • Don’t write a GUI which you hope others will find useful. Write one you use yourself and hopefully it may be of use other people • A successful GUI will requires the right balance of detail and simplicity • Writing a GUI using R may not be the optimal deployment of a GUI, but it is nevertheless easy to do! • “It is my opinion that programing from within R is a very good way to get a working GUI quickly, but you are better served leaving R for something polished and professional looking.” R-Blogger

  21. Thank you!

More Related