GUI to subset a data frame in R

I am building a custom GUI in R for work, and I need to have a part that can select a subset of a dataframe based on variable values (i.e. select all females that are above 50 etc.). I am building the GUI with gwidgets, but I am stuck with regards to how this filter can be implemented. Specifically how to create a widget that allows the user to select one or more filters and then return the filtered data frame.

Here is a small sample from the data I am working with:

structure(list(kunde = c(3, 3, 3, 3, 3, 3, 3, 1, 3, 3), 
               bank = c(7,98, 3, 3, 98, 2, 2, 1, 7, 2)),
          .Names = c("kunde", "bank"), row.names = c(NA, 10L), class = "data.frame")

Any help is greatly appreciated!!


There are some examples of similar things in the ProgGUIinR package. Here is one of them:

d <- available.packages()       # pick a cran site

w <- gwindow("test of filter")
g <- ggroup(cont=w, horizontal=FALSE)
ed <- gedit("", cont=g)
tbl <- gtable(d, cont=g, filter.FUN="manual", expand=TRUE)

ourMatch <- function(curVal, vals) {
  grepl(curVal, vals)

id <- addHandlerKeystroke(ed, handler=function(h, ...) {
  vals <- tbl[, 1, drop=TRUE]
  curVal <- svalue(h$obj)
  vis <- ourMatch(curVal, vals)
  visible(tbl) <- vis

For your purpose, you might want to use gcheckboxgroup or gcombobox to select factor levels or a level and filter by that. The key is the visible<- method of the gtable object is used to filter the displayed items.

If you are game, you can try the gfilter widget in gWidgets2 which as of know is just on my github site (use install_packages("gWidgets2", "jverzani") from devtools, also gWidgets2RGtk2). This may be just what you are trying to do.

Need Your Help

Represent XSD choice elements into LiveCycle Designer PDF forms

xml xsd adobe livecycle pdf-form

I'm using Adobe Livecycle Designer and XML files to create some PDF forms for a project. I created an XSD, which among others contains an unbounded sequence of choices, for example something like the

Is it possible to add an element to the bottom tool bar of a navigation controller?

iphone uinavigationcontroller uiprogressview

I want to add a progressview and an activity indicator view to the tool bar that come at the bottom of the navigation controller. But when I drag and drop it, it becomes applicable to the whole win...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.