[R-pkgs] RGtk2Extras package for dataframe editing and easy dialog creation

From: Taverner, Thomas <Thomas.Taverner_at_pnl.gov>
Date: Wed, 26 Jan 2011 12:10:15 -0800


Dear useRs,

This is to announce the RGtk2Extras R package is available on CRAN in version 0.5.1.

This package provides useful extras for R programmers who wish to create graphic user interfaces. It is based on GTK, using Michael Lawrence's RGtk2 package and John Verzani's gWidgets, and some ideas from John Verzani's traitr package.

The first major feature of RGtk2Extras, the run.dialog function, is an interface for creating simple front-ends to R functions using a terse markup scheme. No GUI knowledge is required; if you can write an R function, you can create a dialog for it.

An example:

# A function with one argument, N

  Histogram = function(N) hist(rnorm(N))

# Dialog markup list for the function Histogram
# Create the main dialog label with the first "label=" (optional)
# Then specify N.integerItem=50, where
# (1) N is the function argument
# (2) integerItem is the type of widget to use, see ?run.dialog
# (3) the value 50 is the default
# Then with the second "label=" add a label for the "N" item (optional)

  Histogram.dialog = list(label = "Histogram of N points",     N.integerItem = 50, label = "Value of N")   

# Run the dialog.
# The returned list has elements "args" for dialog arguments
# and "retval" for the return value.
# With auto.assign=TRUE, the return value is stored in "Histogram_output".
# run.dialog also does error handling, interrupts and an optional
# progress bar dialog for long running tasks, see ?run.dialog

  a = run.dialog(Histogram)

A more complex demo example, thanks to Graham Williams:

  demo(MakeAngle)

The second feature of RGtk2Extras is gtkDfEdit, an editable spreadsheet widget designed for editing data matrices and data frames. It's also based on RGtk2. This was released earlier as RGtk2DfEdit which was then folded into RGtk2Extras.

The gtkDfEdit spreadsheet is quite full featured and has been designed to be familiar to Excel users, while allowing most of the data frames and factor operations that are possible from the R command line.

Data frame columns are type-aware and there is a factor editor. Most functions can be accessed from right clicking on data columns or cells. There is undo, cross platform copy/paste, sorting, cell filling, and data loading capabilities. See ?gtkDfEdit.

The widget provided by gtkDfEdit() can be integrated into larger RGtk2 based user interfaces, or its standalone wrapper dfedit() can be used as a straight replacement for edit.data.frame().

There is also a basic API for manipulating and binding event handlers to the spreadsheet. See ?gtkDfEditDoTask and ?gtkDfEditSetActionHandler.

# Edit the iris data frame
# Note the blank row at the bottom to allow pasting into rows below. x = dfedit(iris)

# Example user interactions
1. Right click the "Species" column or column header to see or change the data type. Click "Edit Factors" to change factor levels or ordering.

2. Right click a column header and then click "Sort" to sort columns

3. Right click column header and change data type by selecting "Character"/"Integer" etc. Factors can be changed to integer levels ("To Factor Levels") or integers ("To Factor Ordering")

4. Right click column header to insert or delete columns or change column name.

5. Select a submatrix of numbers within "iris" and press the "=" key to bring up the Command Editor, then type "hist" in the command field and "OK" to create a histogram of the submatrix; "function(x) hist(x)" works as well.

6. Select a submatrix within "iris" and press Ctrl-V or right-click and select Copy to copy into an external spreadsheet; Ctrl-C works to paste into the data frame. Ctrl-Shift-C copies submatrix and row and column names. (The equivalent Mac keys should also work.)

7. Select a range of cells within "Species" column and right-click to select "Fill in Cycles" to fill cyclic factors.

8. Right click left hand corner cell to open CSV file into editor or save as file.

9. Right click left hand corner cell and "Default Columns" to set columns to default Excel-style column headers.

  1. Ctrl-Z to undo previous edits. # End of examples

RGtk2Extras is still in a beta stage of development. It is hosted on r-forge.r-project.org/R/?group_id=924. Comments and suggestions appreciated; email thomas.taverner _AT_ pnl.gov

Thanks to the entire R community, particularly the R Development Core Team, Michael Lawrence and John Verzani, and also Graham Williams and Iago Conde for comments.

Tom



R-packages mailing list
R-packages_at_r-project.org
https://stat.ethz.ch/mailman/listinfo/r-packages Received on Thu 27 Jan 2011 - 08:33:42 EST

This archive was generated by hypermail 2.2.0 : Thu 27 Jan 2011 - 08:40:02 EST