rp.slider {rpanel}R Documentation

Slider for an rpanel

Description

Add a slider to the panel, to graphically control a numeric variable.

Usage

rp.slider(panel, var, from, to, action = I, title = deparse(substitute(var)), 
          log = FALSE, showvalue = FALSE, resolution = 0, initval = NULL, 
          parent = window, pos = NULL, horizontal = TRUE, ...)

Arguments

panel

the panel in which the slider appears. This may be passed as a panelname string or the panel object itself.

var

the name of the variable that the slider controls.

from

the lower limit of the range of values to which the slider can be set.

to

the upper limit of the range of values to which the slider can be set.

log

a logical variable which controls whether the scale of the slider is logarithmic.

showvalue

a logical variable which determines whether the present value of "var" is shown. This is forced to FALSE when log is TRUE.

resolution

the resolution of the slider scale. If > 0, all values are rounded to an even multiple of this value. The default is 0.

action

the function which is called when the slider is moved.

title

the label of the slider.

initval

the initial value of var (optional). The initial value can also be specified in the call to rp.control.

parent

this specifies the widget inside which the slider should appear. In the current version of rpanel, it should not normally be used.

pos

the layout instructions. Please see the rp.pos example and help for full details.

horizontal

a logical variable determining whether the slider is displayed horizontally (or vertically).

...

information for pos can be passed individually as additional arguments.

Details

The function action should take one argument, which should be the panel to which the slider is attached.

See rp.grid for details of the grid layout system.

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 panel's environment 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.

Note that setting log=TRUE and showvalue=TRUE is not allowed. The slider value shown would be incorrect (it wouldn't be the log value) and so showvalue is over-ridden and set to FALSE. A new widget rp.label is under development which would be used in these circumstances.

References

rpanel: Simple interactive controls for R functions using the tcltk package. Journal of Statistical Software, 17, issue 9.

See Also

rp.radiogroup,rp.control

Examples

if (interactive()) {
   density.draw <- function(panel) {
     plot(density(panel$x, bw = panel$h))
     panel
     }
   panel <- rp.control(x = rnorm(50))
   rp.slider(panel, h, 0.5, 5, log = TRUE, action = density.draw)
   }

[Package rpanel version 1.0-6 Index]