[R-gui] New package RGtk2DfEdit: a spreadsheet for RGtk2

Taverner, Thomas Thomas.Taverner at pnl.gov
Wed Feb 17 22:20:45 CET 2010


Dear useRs,

I would like to bring to your attention the RGtk2DfEdit package, released
recently and currently in version 0.5.3.1. This package provides an RGtk2 based
data frame viewer/editor intended to be familiar to spreadsheet users. It is
based on Michael Lawrence and Duncan Temple Lang's R bindings for Gtk.

The gtkDfEdit function in the package provides a cross-platform widget for
viewing, interacting with and manipulating a data frame, based on an underlying
RGtkDataFrame object and a specified linked data frame located in the global
environment.

Edits made in the grid displayed in the widget will appear instantly in the
data frame in the global environment. (Fortunately, there is undo capability
via Ctrl-z)

The package can form part of other RGtk2 based GUI projects. For example,
gdfedit in John Verzani's current gWidgetsRGtk2 release (0.0-59) provides a
front end to the RGtk2DfEdit package.

As well as hopefully being useful for R GUI developers, the package may
eventually hold interest for a general audience of R users, since it offers
some features that edit.data.frame does not have, for example, in handling and
editing factors.

The project is still in an early stage of development and has many bugs.
Any suggestions are welcome.

An example, using the function dfedit to open a gtkDfEdit frame in its own
window (in R 2.10.1 on 32-bit Windows)

install.packages("RGtk2DfEdit")

?gtkDfEdit

#  # Alternative construction using gtkDfEdit
# win <- gtkWindowNew()
# obj <- gtkDfEdit(iris)
# win$add(obj)

obj <- dfedit(iris)
obj[1,1,drop=FALSE]

  # select some cells
obj$getSelection()
obj$setColumnName(1, "hi there")
obj$setColumnClickHandler(function(obj, col) print(obj[,col]))
 # click a column


The editor includes the following features:

* Familiar modes of editing, keyboard handling and navigation

* Named, floating row and column labels

* Editing row and column names by double clicking the corresponding label

* Support for different data types and coercion - right-click on column headers
  to view and coerce the data type.

* Familiar modes of copying, pasting and selecting cells, rows and columns

* Copy and paste support (Ctrl-c, Ctrl-v) - requires xclip and xsel on Linux.

* Undo (Ctrl-z) support for many manipulations

* Seamlessly updating the linked R object in the global environment

* Reasonably fast loading of large data frames - it remains usable with millions
  of rows, although improvements are planned.

* Cross platform, however, cairoDevice is not available on Mac and future
  releases will make this optional.

* Reassignment of data frame to different object - double click in the left
  top corner box to edit the dataframe's name.

* Support for editing factor levels, the level order and the level contrasts -
  via the Factor Editor option in a factor column right click menu or the
  cell right click menu over a factor column.

* Support for spreadsheet-style sorting of data frames with arbitrary numbers of
  Keys, including coercion of keys: via the Sort option in the column or corner
  button right click menu.

* Autocomplete for factor entries

* Right click on a selection within a column to get options to fill it
  with factor levels in various ways (Randomize, Fill Down, Fill Cyclic
  (for factors)

* S3 methods:
The "[" method is used for data-frame like extraction from the object.

The $getSelection method returns a list of selected row and column indices.

The $getModel method returns the backing RGtkDataFrame.

The $getDimension method returns the backing data frame dimension.

The $getColumnNames method returns the column names.

The $getRowNames method returns the row names.

The $setColumnName(idx, new.name) method sets the column name at a particular
index.

The $setColumnClickHandler and $setRowClickHandler method sets a function to
handle clicking on a column or row with signature (data.frame, col.index)

Thanks to John Verzani for contributions, early feedback and writing the
gWidgets package, Michael Lawrence and Duncan Temple Lang for their work on
RGtk2 and cairoDevice, and Kurt Hornik and all the R-Core team for their
great work.

Tom



More information about the R-SIG-GUI mailing list