rp.doublebutton {rpanel}R Documentation

Double-button widget for rpanel

Description

Adds a widget with '+' and '-' buttons, to increment and decrement a variable.

Usage

rp.doublebutton(panel, var, step, title = deparse(substitute(var)), action = I, 
initval = NULL, range = c(NA, NA), log = FALSE, repeatinterval = 100, 
repeatdelay = 100, parent = window, pos = NULL)

Arguments

panel the panel in which the doublebutton should appear. This may be passed as a panelname string or the panel object itself.
var the name of the variable within the panel that the doublebutton should control.
step the value by which the variable "var" is incremented or decremented on pressing a button. When log is TRUE this is a factor instead.
action the function which is called when a button is pressed.
title the label for the doublebutton. This defaults to the name of var.
parent this specifies the widget inside which the this widget should appear. In the current version, it should not normally be used.
initval the initial value for var (optional). The initial value can also be specified in the call to rp.control.
range a 2-element numeric vector containing lower and upper limits for var. Use NA for no limit (upper and/or lower).
log a logical variable which determines whether the increment (step) is multiplicative or additive.
repeatinterval the interval between auto-repeats (milliseconds) when the button is held down.
repeatdelay the time after which the button starts to auto-repeat (milliseconds).
pos the layout instructions. Please see the rp.pos example and help for full details.

Details

action should be a function of one argument, which should be the panel. The panel can then be manipulated, and data stored in the panel may be used/modified, then the (optionally modified) panel must be returned.

Value

If the parameter panel is the panelname string the same string is returned. If the panel object is used the altered panel is assigned to both the calling level and global level.

Warning

The action function should return the panel. Without this assignment any widgets added or alterations made to panel parameters within the action function will be lost.

References

rpanel: Simple interactive controls for R functions using the tcltk package (http://www.stats.gla.ac.uk/~adrian/research-reports/rpanel.ps)

See Also

rp.radiogroup,rp.control

Examples

density.draw <- function(panel) {
  plot(density(panel$x, bw = panel$h))
  panel
}
panel <- rp.control(x = rnorm(50))
rp.doublebutton(panel, var = h, step = 0.05, 
  title = "Density estimate", action = density.draw,
  range = c(0.1, 5), initval=1)

[Package rpanel version 1.0-3 Index]