rp.radiogroup: Radiobuttons for a panel

View source: R/radiogroup.r

rp.radiogroupR Documentation

Radiobuttons for a panel

Description

This function adds a set of radiobuttons to the panel. When a radiobutton is pressed, a variable is set and an action function is called.

Usage

rp.radiogroup(panel, variable, vals, labels=NULL, initval=vals[1], pos=NULL, 
  title=deparse(substitute(variable)), 
  action=I, foreground=NULL, background=NULL, font=NULL, 
  parentname=deparse(substitute(panel)), name=paste("radiogroup", .nc(), sep=""), ...)

Arguments

panel

the panel in which the radiobuttons should appear.

variable

the name of the variable whose values are set by the buttons.

vals

the values attached to the labels for return from the action function. NOTE: for implementation.

labels

the labels for the radiobuttons.

initval

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

pos

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

title

the label for the group of radiobuttons.

action

the function which is called when a button is pressed.

foreground

colour of the text

background

colour of the text background

font

font to be used

parentname

this specifies the widget inside which the radiogroup should appear.

name

name assigned to the listbox, used for disposing of the widget

...

...

Details

The function action should take one argument, which should be the panel to which the radiobuttons are attached.

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

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.

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. Journal of Statistical Software, 17, issue 9.

See Also

rp.checkbox, rp.control

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")     

## End(Not run)

rpanel documentation built on Feb. 16, 2023, 10:37 p.m.

Related to rp.radiogroup in rpanel...