Deducer : A Data Analysis GUI for R

While R has proven itself to be a powerful and ﬂexible tool for data exploration and analysis, it lacks the ease of use present in other software such as SPSS and Minitab . An easy to use graphical user interface (GUI) can help new users accomplish tasks that would otherwise be out of their reach, and improves the eﬃciency of expert users by replacing ﬁfty key strokes with ﬁve mouse clicks. With this in mind, Deducer presents dialogs that are understandable for the beginner, and yet contain all (or most) of the options that an experienced statistician, performing the same task, would want. An Excel -like spreadsheet is included for easy data viewing and editing. Deducer is based on Java ’s Swing GUI library and can be used on any common operating system. The GUI is independent of the speciﬁc R console and can easily be used by calling a text-based menu system. Graphical menus are provided for the JGR console and the Windows R GUI.


Introduction
R (R Development Core Team 2012) is a powerful statistical programming language that places the latest statistical techniques at one's fingertips through thousands of add-on packages available on the Comprehensive R Archive Network (CRAN) download servers. The price for all of this power is complexity. Because R analyses must be called as text commands, the user is required to find out the name of the function that will accomplish their task, and then remember that name along with the names of the variables to feed it, and its argument options. Perhaps more fundamentally, many users have never dealt with a program that requires them to type in commands that manipulate objects in the program.
For beginners, Deducer is designed to be an intuitive dialog based interface to common data manipulation and analysis tasks. It requires no initial knowledge of the R programming language. Data can be loaded, edited, and analyzed through graphical user interface (GUI) components without understanding the command functions. Output is sent to the console, and custom R functions format the results into easy to read tables.
For expert R users, Deducer reduces the time necessary to construct a command, and minimizes the cognitive load of remembering infrequently used options. Otherwise, Deducer stays out of the way. The GUI is integrated into the regular R console, so using a mix of programming and GUI dialogs is natural.

Other R interfaces
There are a number of actively maintained GUI projects for R. Each of these packages are great efforts with their own advantages and disadvantages. Table 1 displays a comparison chart of the major R data analysis GUI efforts.

R Commander
R Commander (Fox 2005) is the most mature GUI project for R. Its dialogs cover an extensive set of analyses, plots, and data manipulation tasks. It also includes an easy to use plug-in system so its scope can be extended by interested programmers. The goal of the package is to facilitate student learning in basic statistics courses with the hope that they will eventually be "weaned off" of the GUI. Deducer, on the other hand, takes the view that a GUI can be useful for experts as well as students, provided it is designed with them in mind.
R Commander has a rich set of plug-in packages that greatly extend the scope of the statistical methods covered by the GUI. See Fox and Carvalho (2012) in this special volume for an example. As of this writing, there are 32 R packages on CRAN that extend or enhance R Commander. They range in subject matter from teaching to text mining, and provide a diverse functionality far outstripping any other R GUI project. That said, from the perspective of a professional data analyst, there are a number of design issues that make it sub-optimal for daily use. These (perhaps subjective) sub-optimalities are what lead to the development of Deducer as a separate project.
Console: R Commander requires the user to use a separate R console which manages the R commands and displays the output, this is a less than ideal set-up for advanced users who are comfortable with the command line. Deducer is integrated with the terminal, the usual Windows console, and JGR.
Task based dialogs: R Commander has separate dialogs for each R function it uses. For example, there are 6 menu items for loading data from a file (one for each loading function), whereas Deducer has one which picks the right function based on extension and user selection.
Pretty GUI toolkit: R Commander uses the Tcl/Tk toolkit to create the interface. Though cross-platform, the widgets are not very nice looking and can deviate from the normal platform look and feel. This is especially true on the Mac, where the non-native X Windows system is used. Deducer uses the Java, which is also cross-platform, but supports a more integrated look and feel with more advanced features such as drag and drop.
Dialog memory: One of the constantly vexing things about R Commander is that the dialogs do not remember what options were selected the last time they were used. Data analysis is an iterative process, it is very rare that the user specifies exactly the right set of options the first time.

Rattle
Rattle (R Analytical Tool To Learn Easily, Williams 2009) is another GUI based on the Gnome graphics system and is focused on data mining rather than classical statistics. As a result, it facilitates analyses in areas such as neural networks, and support vector machines, but provides no way to analyze contingency tables. Like R Commander, Rattle creates a new console window which controls the commands and logs the resulting output. Rattle is limited to working with one dataset and one outcome variable at a time.

RKWard
RKWard (Rödiger, Friedrichsmeier, Kapat, and Michalke 2012) is, perhaps, the most similar project to Deducer in terms of its goals. It features a spreadsheet data editor and a comprehensive R console replacement. Its data analysis features are accessed through menu items, and results are available as neatly formatted HTML tables. Each bit of GUI output is accompanied by a Run again button, which brings up the dialog in the state that was used to generate the results. This facilitates reproducible research, and is a great feature.
Unfortunately, RKWard is in its infancy when it comes to non-Linux systems. There are a number of known issues on Windows, and no binary version is available for the Mac.

Installation
Deducer is compatible with most R consoles, but is best integrated with the JGR console (Helbig, Theus, and Urbanek 2005). Because JGR is Java-based, rJava (Urbanek 2011) takes care of the synchronization issues between JGR's read-eval-print loop and the dialogs' R calls, so the data viewer and dialogs do not need to block the console while open. On Mac OS X, Deducer must be used from within JGR.
Installation is fairly standard as it is available from the CRAN at http://CRAN.R-project. org/package=Deducer. install.packages("Deducer") downloads the latest version from CRAN and installs it. Deducer can then be loaded with library("Deducer"). If Deducer is called from the Windows R GUI, three new menus appear in the menu bar (Deducer, Data and Analysis).
If Deducer is called from the terminal, one can navigate its menus via a text based menu system accessed by calling deducer(). Specific dialogs can be brought up by passing its name to the deducer function. For example deducer("Open Data") will bring up the Open Data dialog with no need to traverse the menu system.     Extensive documentation and video tutorials are available through the online manual (Fellows 2012) which is located at http://www.Deducer.org/manual.html. The information button in the lower left hand corner of each dialog provides access to the part of the manual relevant to that particular task.

Loading and saving data frames
The Open Data dialog JGR and Deducer support a simple yet versatile dialog for bringing in data from a file. The Open Data dialog facilitates the use of the read.table function for text delimited data, and uses the foreign package to load data written in other statistical programs such as SPSS or Minitab. The specific function needed is determined by the file extension, though this can be overridden by selecting a file format from the Format combo box. The R name that this data is loaded to can be changed by entering a value into the Set Name field in the lower left hand corner. The types shown in Table 2 are supported.
If the file is not a text file, or a comma-separated file, it will be loaded into the workspace. Otherwise, a supplemental dialog will be displayed showing a preview of the data file to make sure that all settings are correct.
The Record Separator option allows the user to specify what character separates values in the data set.
The Quote option lets the user define whether the data file defines character variables by surrounding them with quotation marks.
The Header option specifies whether the first row contains the variable names.  The values of these options are intelligently guessed automatically. As the user changes the option values, the results are previewed in the preview table. This allows the user to load data without having to first open it in a supplemental program (such as Notepad) to determine its format.
The R function called by this dialog will depend on the type of data loaded. The example above produces the following read.  temporary.data <-read.table("/Users/Ian/temp.csv", header = TRUE, sep = ",", quote = "\"") The Save Data dialog Saving data to a file is simple, no matter what format the data needs to be in. Using the Save Data dialog in the File menu, data can be saved in any of te formats shown in Table 3.

The Data Viewer
The Data Viewer provides an easy to use, spreadsheet-like environment to view and edit data. Copy and pasting is supported, compatible with Excel 2003/2007, so data can be moved from Excel to R by simply copying it to the Data Viewer. Contextual menus are used to insert, delete and copy rows and columns.
The Data Viewer consists of two tabs, one containing the data table, and the other displaying variable information. The Data View shows the data frame values, which can be copied, Figure 6: The Data View. pasted, or edited in a manner similar to Excel. Right clicking (or command clicking on the Mac) on the row or column headers allows the user to insert, copy, or delete columns and rows.
In the Variable View the properties of each variable in the data frame can be edited. The variable column represents the variable name. The type column determines the storage type. Variables can be converted to and from character, double (numeric), integers, logical (yes/no), factor, date or time. The levels of factors are displayed in the Factor Levels column, and can be edited by clicking on the appropriate cell, bringing up the Factor Editor.

The dialogs
The dialogs are located in the Data and Analysis menus. Unlike some other statistical GUIs, Deducer's dialogs are conceptually organized by task. That is, each dialog represents a specific task that a user might sit down and wish to accomplish. For example, the two-sample test dialog includes the t test, as well as the Wilcoxon rank sum. Even though statistically, these tests belong to two separate families (parametric and non-parametric), from a task-based view, they both answer the same type of question: Are the central tendencies of the two independent samples different?
In addition to GUI dialogs, Deducer introduces quite a few new R functions. Some of these implement statistical algorithms for which no built in R function was available (e.g., permutation t tests, data frame sorting and mid p values for exact tests), others serve to provide a simple unified interface to a number of statistical procedures, and present their results in an easy to read format (e.g., descriptive.table and two.sample.test). There are also a few convenience and utility functions included. One that is used in many of the analysis dialogs is 'd', which is a keystroke saving wrapper function for data.frame.
Detailed instructions for using the dialogs will not be presented, instead, brief functional descriptions and example output will be given. For the interested reader, the online manual (http://www.Deducer.org/manual.html) provides detailed descriptions of each GUI dialog, as well as several analysis examples.

Data manipulation
Before any analysis, the data needs to be manipulated into a form amenable to analysis. De-ducer provides several dialogs that can be helpful in altering the data frame and its variables.
Edit Factor: This dialog can be used to add to, or remove levels of a factor, their order, and the type of contrast used (i.e., treatment, sum, Helmert, or polynomial).
Recode Variables: This dialog uses a custom R function (recode.variables) to transform specific values, or ranges of values, of a variable to new values.
Transform: Provides various variable transformations, including log, square root, standardization, binning, and Box-Cox.
Reset Row Names: Changes the row names of a data frame to integers from 1 to the number of rows.
Sort: Sorts a data frame by any number of variables of any type. Uses a new S3 method for the class data.frame for easy data frame sorting.
Merge: Combines two data frames into one, based on common identifiers. Warnings are given if the identifiers do not uniquely identify observations.

Transpose: Transposes the rows and columns of a data frame
Subset: Creates a subset of a data frame based on a logical expression.

Analysis
The Analysis menu contains dialogs providing descriptive information about variables, as well as inference functions which output p values, confidence intervals, effect sizes, and analysis visualizations. One design principle adhered to was the belief that all analyses should be accompanied by a visualization helping users understand the quantities being tested, and model fit.

Frequencies
Frequency tables provide descriptive information for categorical and ordinal variables. They display the number of cases that fall into each category of a specific variable, and calculate percentages. A new R function frequencies is provided which presents the results in easy to understand tables.
Features: Counts and percentages.

Descriptives
Calculates descriptive statistics for a set of variables, possibly stratified by another set. It supports a number of built-in statistics (e.g., Mean and Standard Deviation), and provides facilities for custom functions to be specified. This dialog uses a new R function descriptive.table which tabulates the statistics into nicely formatted tables.

Contingency Tables
Contingency tables (sometimes called crosstabs) are used to summarize and analyze the joint distribution of two variables, possibly stratified by a third. While R has powerful functions that can be applied to table counts, they spread out over a number of packages, and do not provide easy to read output. Deducer takes a unified approach to contingency tables.
First, a contingency.tables object is created, formed with any number of row or column variables, as well as one stratifying variable. When printed, the tables are formatted and displayed, with optional row and column percentages. Tests can then be added to the object, which causes them to be applied to each

Models
Deducer has an advanced system for constructing, analyzing and visualizing models. The GUI helps the user specify the model formula, which can include interaction and nested terms. Next it presents the user with the model explorer (displayed in Figure 8), which shows a preview of their results, along with options for model testing, assessing model fit, and result visualization. All generalized linear models are supported, including linear and logistic regression models. For several options the car package (Fox and Weisberg 2011) is leveraged.
The tabs at the top of the dialog in Figure 8 present the users with plots to asses the assumptions of the linear model. The icons in the top left outline the major assumptions being made. From left to right these are: No outliers, linearity, equal variance (homoskedasticity), and either normality, or a sufficiently large sample size. The buttons on the right bring up a wide array of options for investigating the regression model, including most of those that a professional analyst would need.
Options: Common model summaries, including ANOVA (type II or III) tables, parameter summaries, heteroskedasticity-consistent covariance matrices (linear model), variance inflation factors, observation influence, and parameter correlations.
Post Hoc: Post-hoc tests/intervals with 10 types of contrasts and 12 types of multiple comparison corrections.
Tests: Linear hypothesis tests.
Means: Post-hoc means with confidence intervals.

Plots
There are two ways to create plots within the GUI. The first is to use the plot builder, which is a graphical interpretation of the grammar of graphics (Wilkinson 1999) as implemented by the ggplot2 package (Wickham 2009). It is a flexible tool, which can create virtually any type of plot. Secondly, Deducer also interfaces with the iplots package (Urbanek and Wichtrey 2011) to provide interactive graphics for data exploration.

Extensibility
An important aspect of Deducer is its ability to be extended by third-party extensions. Once a developer has created a GUI for a particular method, all that is nessisary is to add it to the menu system. For example, if a developer has created a factor analysis GUI that is started when the R code dialog$run() is executed, the following code will add it to the menu system.
A developer can use any programming language or GUI toolkit they feel comfortable with, but the recommended toolkit is Java Swing. Deducer provides a number of GUI components specifically designed for R and data analysis. A full list of these components along with documentation is available on the website.

Conclusion
Deducer's dialogs and R functions make common data analysis tasks in R easier to both perform and interpret. No programming or scripting is required, which opens R to a large audience of users who would otherwise be locked out of experiencing R's power. The breadth of analyses covers most of what would be taught in introductory, and intermediate, applied statistics courses, thus making it appropriate for use in the classroom.
Undoubtedly, there are some omissions from the system, for example only univariate analyses are currently implemented. As Deducer becomes more mature, its breadth will continue to grow. Because statistics is a large and constantly growing subject, there will always be areas that Deducer does not provide a GUI for. However, as Deducer is extensible through a plugin system, any interested party can create a package implementing a GUI for their favorite analysis, which can then be accessed through Deducer's menus.