Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

gfilter

A widget for filtering a data frame


Description

This widget provides a simple means to subset, or filter, a data frame.

generic for toolkit dispatch

The svalue method for a filter object returns a logical containing which rows are selected. There is no assignment method.

The extraction method returns the child items of the filter, like a container object.

Default

Usage

gfilter(DF, allow.edit = TRUE, initial.vars = NULL, handler = NULL,
  action = NULL, container = NULL, ..., toolkit = guiToolkit())

.gfilter(toolkit, DF, allow.edit = TRUE, initial.vars = NULL,
  handler = NULL, action = NULL, container = NULL, ...)

## S3 method for class 'GFilter'
svalue(obj, index = NULL, drop = NULL, ...)

## S3 method for class 'GFilter'
x[i, j, ..., drop = TRUE]

## Default S3 method:
.gfilter(toolkit = guiToolkit(), DF, allow.edit = TRUE,
  initial.vars = NULL, handler = NULL, action = NULL, container = NULL,
  ...)

Arguments

DF

a data frame or GDf instance to look variables up within.

allow.edit

logical. If TRUE a user may add new variables to filter by. If FALSE, then one should specify the variables a user can filter by to initial.vars.

initial.vars

When given, this is a data frame whose first column specifies the variables within DF to filter by and whose second column indicates the type of filter desired. The available types are single to select one from many, multiple, for multiple selection; and range, to specify a from and to value.

handler

A handler assigned to the default change signal. Handlers are called when some event triggers a widget to emit a signal. For each widget some default signal is assumed, and handlers may be assigned to that through addHandlerChanged or at construction time. Handlers are functions whose first argument, h in the documentation, is a list with atleast two components obj, referring to the object emitting the signal and action, which passes in user-specified data to parameterize the function call.

Handlers may also be added via addHandlerXXX methods for the widgets, where XXX indicates the signal, with a default signal mapped to addHandlerChanged (cf. addHandler for a listing). These methods pass back a handler ID that can be used with blockHandler and unblockHandler to suppress temporarily the calling of the handler.

action

User supplied data passed to the handler when it is called

container

A parent container. When a widget is created it can be incorporated into the widget heirarchy by passing in a parent container at construction time. (For some toolkits this is not optional, e.g. gWidgets2tcltk or gWidgets2WWW2.)

...

dots argument

toolkit

Each widget constructor is passed in the toolkit it will use. This is typically done using the default, which will lookup the toolkit through guiToolkit.

obj

object of method call

index

NULL or logical. If TRUE and widget supports it an index, instead of a value will be returned.

drop

NULL or logical. If widget supports it, drop will work as it does in a data frame or perhaps someother means.

x

the GFilter object

i

passed to get_items

j

passed to get_items

Value

returns GFilter object

Examples

## Not run: 
DF <- mtcars[, c("mpg", "cyl", "hp", "am", "wt")]
w <- gwindow("Example of gfilter", visible=FALSE)
pg <- ggroup(container=w)
df <- gtable(DF, container=pg)
a <- gfilter(df, initial.vars=data.frame(names(DF), names(DF),
                   c("single", "multiple", "range", "single", "range"),
                   stringsAsFactors=FALSE),
             allow.edit=TRUE,
             container=pg,
             handler=function(h,...) {
               visible(df) <- h$obj$get_value()
             }
             )
size(w) <- c(600, 600)
visible(w) <- TRUE

## End(Not run)

gWidgets2

Rewrite of gWidgets API for Simplified GUI Construction

v1.0-8
GPL (>= 3)
Authors
John Verzani
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.