rp.do {rpanel} | R Documentation |
Runs a user-written action function
Description
Runs a user-written action function, passing a panel to it as a parameter. This can be used to put the rpanel into its initial state. For example, it is useful when using radiobuttons as these do not automatically call the action function when the controls are first created.
Usage
rp.do(panel, action, x = NA, y = NA)
Arguments
panel |
the panel to be passed as a parameter to the function. |
action |
the function to be executed. |
x , y |
additional arguments for mouse position on the plot, so that the action function can be called with these additional arguments if they are present. |
Value
If the argument 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.
References
rpanel: Simple interactive controls for R functions using the tcltk package. Journal of Statistical Software, 17, issue 9.
See Also
Examples
## Not run:
data.plotfn <- function(panel) {
if (panel$plot.type == "histogram")
hist(panel$x)
else
if (panel$plot.type == "boxplot")
boxplot(panel$x)
else
plot(density(panel$x))
panel
}
panel <- rp.control(x = rnorm(50))
rp.radiogroup(panel, plot.type,
c("histogram", "boxplot", "density estimate"),
action = data.plotfn, title = "Plot type", initval="histogram")
rp.do(panel, data.plotfn)
## End(Not run)