RKWard – a cross-platform and development environment for

dipl.-psych. thomas friedrichsmeier ruhr university bochum dipl.-psych. m.eik michalke heinrich heine university düsseldorf

11.III.2015 GUIs for R

RKWard dialogs console/editor data plots packages extendable plugin concept rkwarddev GUIs for R summary thx

t· friedrichsmeier & m· michalke | RUB · HHU | http://rkward.kde.org RKWard | GUIs for R

GUIs for R

RKWard JSS special volume 49: dialogs »graphical user interfaces for R« console/editor data plots packages

JSS Journal of Statistical Software JSS Journal of Statistical Software extendable June 2012, Volume 49, Issue 1. http://www.jstatsoft.org/ June 2012, Volume 49, Issue 9. http://www.jstatsoft.org/ plugin concept rkwarddev Graphical User Interfaces for R RKWard: A Comprehensive Graphical User Interface and Integrated Development Environment Pedro M. Valero-Mora Rub´enD. Ledesma for Statistical Analysis with R summary Universitat de Val`encia Universidad Nacional de Mar del Plata Stefan R¨odiger Thomas Friedrichsmeier Abstract Charit´e-Universit¨atsmedizin Berlin Ruhr-University Bochum Since R was first launched, it has managed to gain the support of an ever-increasing percentage of academic and professional statisticians. However, the spread of its use Prasenjit Kapat Meik Michalke thx among novice and occasional users of statistics have not progressed at the same pace, which The Ohio State University Heinrich Heine University Dusseldorf¨ can be atributed partially to the lack of a graphical user interface (GUI). Nevertheless, this situation has changed in the last years and there is currently several projects that have added GUIs to R. This article discusses briefly the history of GUIs for data analysis and then introduces the papers submitted to an special issue of the Journal of Statistical Abstract Software on GUIs for R. R is a free open-source implementation of the S statistical computing language and Keywords: GUI, statistical software, R. programming environment. The current status of R is a command line driven interface with no advanced cross-platform graphical user interface (GUI), but it includes tools for building such. Over the past years, proprietary and non-proprietary GUI solutions have emerged, based on internal or external tool kits, with different scopes and technological concepts. For example, Rgui.exe and Rgui.app have become the de facto GUI on the Windows and Mac OS X platforms, respectively, for most users. In this paper 1. Introduction we discuss RKWard which aims to be both a comprehensive GUI and an integrated devel- opment environment for R. RKWard is based on the KDE software libraries. Statistical Nowadays, graphical user interfaces (GUIs) are the most common way of interacting with procedures and plots are implemented using an extendable plugin architecture based on a computer or other electronic devices. Whereas they are arguably not the best way of ECMAScript (JavaScript), R, and XML. RKWard provides an excellent tool to manage different types of data objects; even allowing for seamless editing of certain types. The performing every conceivable job, its dominance has reached the principal operative systems, objective of RKWard is to provide a portable and extensible R interface for both basic application domains, and tasks. Measured it in purely statistical terms, the triumph of this and advanced statistical and graphical analysis, while not compromising on flexibility and style of interaction is unquestionable and it seems clear that it will remain very popular in modularity of the R programming environment itself. the foreseeable future. However, regarding the discipline of statistics, this supremacy does not seem so dramatically Keywords: GUI, integrated development environment, plugin, R. clear, as many of the people working in this field seem to favor that using a typed language via a command line interface (CLI) is a much more productive, accurate and reproducible way of performing their tasks than a GUI. Actually, we are positive that they are right, because writing up commands can be undoubtedly much more productive than using a GUI, as far as 1. Background and motivation the learning cost is not included in the bill. Thus, although getting the knowledge to manage a command-based language is within reason if you are going to use it very often, the novice In mid 1993 Ihaka and Gentleman published initial efforts on the computing language and and occasional users of statistical software may not ever see sufficient returns to justify the programming environment R on the s-news mailing list. Ambitions for this project were to

t· friedrichsmeier & m· michalke | RUB · HHU | http://rkward.kde.org GUIs for R

RKWard dialogs console/editor data plots packages extendable plugin concept rkwarddev summary thx RKWard

t· friedrichsmeier & m· michalke | RUB · HHU | http://rkward.kde.org RKWard | about

GUIs for R RKWard I combines GUI and IDE dialogs console/editor B to satisfy both newbies and gurus data plots B easy to extend packages I mere desktop application extendable plugin concept B no server, but R backend configurable rkwarddev I multi-platform summary B MS Windows thx B OS X B GNU/

I free software (GPL v2+) I download: http://rkward.kde.org

B part of the KDE family B 47 official releases since 2002

t· friedrichsmeier & m· michalke | RUB · HHU | http://rkward.kde.org GUIs for R

RKWard dialogs console/editor data plots packages extendable plugin concept rkwarddev summary thx main window

t· friedrichsmeier & m· michalke | RUB · HHU | http://rkward.kde.org RKWard | main window RKWard | main window: workspace browser RKWard | main window: file browser RKWard | main window: R console RKWard | main window: debugger RKWard | main window: online help RKWard | main window: results in HTML GUIs for R

RKWard dialogs console/editor data plots packages extendable plugin concept rkwarddev summary thx dialogs

t· friedrichsmeier & m· michalke | RUB · HHU | http://rkward.kde.org RKWard | dialog windows

GUIs for R

RKWard dialogs data analysis plots console/editor data plots packages extendable plugin concept rkwarddev summary thx

t· friedrichsmeier & m· michalke | RUB · HHU | http://rkward.kde.org RKWard | dialogs: power analysis

GUIs for R

RKWard dialogs console/editor data plots packages extendable plugin concept rkwarddev summary thx

t· friedrichsmeier & m· michalke | RUB · HHU | http://rkward.kde.org RKWard | dialogs: mandatory fields

GUIs for R

RKWard dialogs console/editor data plots packages extendable plugin concept rkwarddev summary thx

t· friedrichsmeier & m· michalke | RUB · HHU | http://rkward.kde.org RKWard | dialogs: code

GUIs for R

RKWard dialogs console/editor data plots packages extendable plugin concept rkwarddev summary thx

t· friedrichsmeier & m· michalke | RUB · HHU | http://rkward.kde.org RKWard | dialogs: wizard

GUIs for R

RKWard dialogs console/editor data plots packages extendable plugin concept rkwarddev summary thx

t· friedrichsmeier & m· michalke | RUB · HHU | http://rkward.kde.org RKWard | dialoge: online help GUIs for R

RKWard dialogs console/editor data plots packages extendable plugin concept rkwarddev summary thx R console & code editor

t· friedrichsmeier & m· michalke | RUB · HHU | http://rkward.kde.org RKWard | R console & code editor

GUIs for R

RKWard dialogs console/editor data plots packages extendable I plugin concept rkwarddev I code hinting summary I code folding thx

t· friedrichsmeier & m· michalke | RUB · HHU | http://rkward.kde.org GUIs for R

RKWard dialogs console/editor data plots packages extendable plugin concept rkwarddev summary thx working with data import/edit/export

t· friedrichsmeier & m· michalke | RUB · HHU | http://rkward.kde.org RKWard | data import/export

GUIs for R

RKWard dialogs console/editor data plots packages extendable plugin concept rkwarddev summary thx

t· friedrichsmeier & m· michalke | RUB · HHU | http://rkward.kde.org RKWard | import SPSS files

GUIs for R

RKWard dialogs console/editor data plots packages extendable plugin concept rkwarddev summary thx

t· friedrichsmeier & m· michalke | RUB · HHU | http://rkward.kde.org RKWard | data.frame editor RKWard | export CSV files

GUIs for R

RKWard dialogs console/editor data plots packages extendable plugin concept rkwarddev summary thx

t· friedrichsmeier & m· michalke | RUB · HHU | http://rkward.kde.org GUIs for R

RKWard dialogs console/editor data plots packages extendable plugin concept rkwarddev summary thx plots preview, history & export

t· friedrichsmeier & m· michalke | RUB · HHU | http://rkward.kde.org RKWard | plot preview, history & export

GUIs for R

RKWard dialogs console/editor data plots packages extendable plugin concept rkwarddev summary thx

t· friedrichsmeier & m· michalke | RUB · HHU | http://rkward.kde.org RKWard | export to TikZ format (LATEX) GUIs for R

RKWard Sales development 2003-2009 dialogs console/editor Illegal downloads (tracks) 600 data CD sales (albums) plots Payed downloads (tracks) CD sales (singles)

packages 500 Payed downloads (bundles) extendable

plugin concept 400 rkwarddev

summary 300 thx 200 Sales/downloads in millions 100 0

2003 2004 2005 2006 2007 2008 2009

Data: Financial reports Bundesverband Musikindustrie, 2004-2009

t· friedrichsmeier & m· michalke | RUB · HHU | http://rkward.kde.org GUIs for R

RKWard dialogs console/editor data plots packages extendable plugin concept rkwarddev summary thx package management

t· friedrichsmeier & m· michalke | RUB · HHU | http://rkward.kde.org RKWard | R packages: installed locally

GUIs for R

RKWard dialogs console/editor data plots packages extendable plugin concept rkwarddev summary thx

t· friedrichsmeier & m· michalke | RUB · HHU | http://rkward.kde.org GUIs for R

RKWard dialogs console/editor data plots packages extendable plugin concept rkwarddev summary thx plugin concept

t· friedrichsmeier & m· michalke | RUB · HHU | http://rkward.kde.org RKWard | the plugin concept

GUIs for R

RKWard dialogs console/editor data plots packages extendable I dialogs are implemented as plugins plugin concept rkwarddev I you can extend RKWard with your own plugins summary B can be installed as R packages thx

t· friedrichsmeier & m· michalke | RUB · HHU | http://rkward.kde.org RKWard | R packages: RKWard plugins

GUIs for R

RKWard dialogs console/editor data plots packages extendable plugin concept rkwarddev summary thx

t· friedrichsmeier & m· michalke | RUB · HHU | http://rkward.kde.org RKWard | plugins: XML & JavaScript

GUIs for R

RKWard dialogs console/editor data plots packages extendable plugin concept rkwarddev summary thx

t· friedrichsmeier & m· michalke | RUB · HHU | http://rkward.kde.org RKWard | example: radio button

GUIs for R RKWard radio button: define GUI in XML dialogs console/editor extendable plugin concept rkwarddev summary thx

t· friedrichsmeier & m· michalke | RUB · HHU | http://rkward.kde.org RKWard | example: radio button

GUIs for R

RKWard dialogs radio button: generate R code with JavaScript console/editor var hypothesis = getValue("hypothesis"); data var x = getValue("x"); plots var y = getValue("y"); packages echo("result <- t.test (x="+x+ ", y=" + y); extendable echo(", alternative=\"" + hypothesis +"\"\n"); plugin concept rkwarddev summary thx

t· friedrichsmeier & m· michalke | RUB · HHU | http://rkward.kde.org GUIs for R

RKWard dialogs console/editor data plots packages extendable plugin concept rkwarddev summary thx rkwarddev

t· friedrichsmeier & m· michalke | RUB · HHU | http://rkward.kde.org RKWard | rkwarddev: documentation

GUIs for R RKWard how-to as vignette in the package dialogs console/editor data plots

packages RKWard plugin development with the rkwarddev package extendable Now, wouldn’t it be nice to see how that looks like in RKWard? Well, you can: > rk.plugin.skeleton( m.eik michalke + about="Example plugin", plugin concept + xml=list(dialog=myDialog), November 9, 2014 + load=TRUE, + show=TRUE rkwarddev + ) Writing plugins for RKWard means writing at least two XML files (a For filenames ‘Example plugin’ was renamed to ‘Exampleplugin’. GUI description and a plugin map), one JavaScript file (to create the R Created directory /tmp/Rtmp9gdThb/Exampleplugin. code), maybe a help file (again in XML), and for plugins who should be Created directory /tmp/Rtmp9gdThb/Exampleplugin/R. distributed, a DESCRIPTION file. Furtermore, all of these files need to Created directory /tmp/Rtmp9gdThb/Exampleplugin/inst/rkward/plugins. be in a certain directory structure. Created directory /tmp/Rtmp9gdThb/Exampleplugin/inst/rkward/tests/Exampleplugin. summary The rkwarddev package aims to simplify this, by enabling you to fulfill For filenames ‘Example plugin’ was renamed to ‘Exampleplugin’. all the listed tasks in just one R script. For filenames ‘Example plugin’ was renamed to ‘Exampleplugin’. For filenames ‘Example plugin’ was renamed to ‘Exampleplugin’. For filenames ‘Example plugin’ was renamed to ‘Exampleplugin’. 1 About the package [1] "/tmp/Rtmp9gdThb/Exampleplugin" thx You might ask why you should write R scripts to generate plugins, if you could just Allthough until now all we did was to outline the XML description of our plugin- directly write the XML and JavaScript files. First of all, you don’t have to use this to-become, rkwarddev can already generate a full plugin. load=TRUE makes sure that package at all, it’s totally fine to code your plugins how ever you like. The main RKWard recognizes the new plugin immediately after it was created, and show=TRUE reason why I wrote this package is that I like to really concentrate on what I’m doing, will even make it pop up, too: so this is my attempt to avoid the need to switch between several files in three different languages all the time. I wanted to be able to constantly ”think in R“ while working on a plugin, and to oversee everything that matters in one script. As a side effect, a lot of useful automation was implemented, so using this package will definitely save you quite some amount of typing.

2 Before we start

It is important to understand that while rkwarddev can help you to make designing new plugins much easier, you still need to know how the generated XML and JavaScript files work and interact. That is, if you didn’t yet read the Introduction to Writing Plugins for RKWard,1 please do so before you start working with this package. Once you’re sure you understand how plugins in RKWard actually work, just come back here. Not bad for less than 20 short lines of code. This makes dialog design both very efficient and flexible: Imagine you want to re-arrange the order of elements, or exper- 1http://rkward.sourceforge.net/documents/devel/plugins/index.html iment with completely different tabbook layouts, all you need to do is to change the

1 7

t· friedrichsmeier & m· michalke | RUB · HHU | http://rkward.kde.org RKWard | XML with rkwarddev

GUIs for R

RKWard dialogs console/editor data functions for XML & JavaScript plots > hypo <- rk.XML.radio(label="using test hypothesis", id.name="hypothesis", packages + options=list( extendable + "Two-sided"=c(val="two.sided"), + "First is greater"=c(val="greater"), plugin concept + "Second is greater"=c(val="less") rkwarddev + ) summary + ) > hypo thx > cat(echo(", alternative=\"", hypo, "\"\n")) echo(", alternative=\"" + hypothesis + "\"\n");

t· friedrichsmeier & m· michalke | RUB · HHU | http://rkward.kde.org RKWard | rkwarddev: start scripting with a GUI

GUIs for R

RKWard dialogs console/editor data plots packages extendable plugin concept rkwarddev summary thx

t· friedrichsmeier & m· michalke | RUB · HHU | http://rkward.kde.org GUIs for R

RKWard dialogs console/editor data plots packages extendable plugin concept rkwarddev summary thx take home message

t· friedrichsmeier & m· michalke | RUB · HHU | http://rkward.kde.org RKWard | summary

GUIs for R

RKWard dialogs console/editor I multi-platform GUI and IDE for R data plots import/edit/export data packages I extendable B dialogs for common statistics & graphs plugin concept rkwarddev I functionality easy to extend summary B XML/JavaScript, rkwarddev thx I excellent for teaching stats

B and package development

I download: http://rkward.kde.org

I feedback: [email protected]

t· friedrichsmeier & m· michalke | RUB · HHU | http://rkward.kde.org GUIs for R thx! RKWard dialogs console/editor questions? ideas? comments? data plots packages twitter: @yrlaNor extendable plugin concept references rkwarddev summary I RKWard Development Team (2015). RKWard Version 0.6.3. thx http://rkward.kde.org I Rödiger, S., Friedrichsmeier, T., Kapat, P. & Michalke, M. (2012). RKWard: A comprehensive graphical user interface and integrated development environment for statistical analysis with R. Journal of Statistical Software, 49(9). I Michalke, M. (2015). rkwarddev: A collection of tools for RKWard plugin development. version 0.06-5. http://files.kde.org/rkward/R/pckg/rkwarddev/ I R Core Team (2014). Writing R Extensions Version 3.1.2. http://cran.r-project.org/doc/manuals/R-exts.pdf

t· friedrichsmeier & m· michalke | RUB · HHU | http://rkward.kde.org