rp.control {rpanel}R Documentation

Create an rpanel

Description

This function creates a panel window into which rpanel widgets can be placed. It also returns, and can set up variables within, the rpanel object.

Usage

rp.control(title = "", size = c(100, 100), panelname, realname, aschar = TRUE, ...)

Arguments

title

the title of the panel displayed in the banner.

size

a two-element numeric vector specifying width and height of the panel in pixels. If this argument is omitted the size of the panel will adapt to the subsequent addition of widgets.

panelname

the name of the panel at .rpenv. If this is not assigned, then realname is taken.

realname

retained for backward compatibility. If this is not assigned, the realname is assigned automatically using rp.panelname.

aschar

if TRUE (default) the panel's name as a string is returned. If FALSE the panel list itself is returned.

...

additional arguments which are treated as variable initialisations and are stored within the returned rpanel object. For example inserting x=3 creates a variable x in the rpanel object with the value 3. Note that the names of these additional arguments should not conflict with those of the main arguments of rp.control.

Details

On some machines the R and Tcl/Tk code can become out of step if a large number of objects, or objects of large size, are passed in .... This can lead to the panel failing to size itself appropriately. A solution is to insert a Sys.sleep(0.5) instruction immediately after the call to rp.control, to ensure that sufficient time is allowed for the initialisation to complete. Clearly, the duration of the sleep time may need to be adjusted on different machines.

Value

Dependent on parameter ischar. If ischar is TRUE this is the string name of the panel if FALSE this is the list object which defines the panel.

References

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

See Also

rp.button,rp.slider,rp.doublebutton,rp.textentry,rp.checkbox,rp.radiogroup

Examples

if (interactive()) {
   hist.or.boxp <- function(panel) {
     if (panel$plot.type == "histogram")
       hist(panel$x)
     else
       boxplot(panel$x)
     panel
   }
   panel <- rp.control(x=rnorm(50))
   rp.radiogroup(panel, plot.type, c("histogram", "boxplot"), title="Plot type", action = hist.or.boxp)  

   # Try also
   # panel <- rp.control(ischar = TRUE) # returns a string ".rpanel1" in panel
   # panel <- rp.control(ischar = FALSE) # returns the panel list object itself
   }

[Package rpanel version 1.0-6 Index]