rp.slider {rpanel} | R Documentation |
Add a slider to the panel, to graphically control a numeric variable.
rp.slider(panel, var, from, to, action = I, title = deparse(substitute(var)), log = FALSE, resolution = 0, initval = NULL, parent = window, pos = NULL)
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. |
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. |
The function action
should take one argument, which should be the panel to which the slider is attached.
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.
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.
rpanel: Simple interactive controls for R functions using the tcltk library (http://www.stats.gla.ac.uk/~adrian/research-reports/rpanel.ps)
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)