rp.textentry {rpanel}R Documentation

Text entry boxes for a panel

Description

This function adds one or more boxes which allow text to be entered.

Usage

rp.textentry(panel, var, action = I, labels = NA, names = labels, title = NA, 
             initval = NA, parent = window, pos = NULL, ...)

Arguments

panel

the panel in which the text entry box(es) should appear. This may be passed as a panelname string or the panel object itself.

var

the name of the variable which will be assigned the text entered into the box(es).

action

the function which is called when the text has been entered.

labels

a character string of labels for the text entry boxes.

names

the names attached to the elements of var. These provide a helpful means of referring to particular items in multiple textentry boxes.

title

a title for the group of text entry boxes. If there is only one box, and labels is not specified, title is taken as the label.

initval

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

parent

this specifies the widget inside which the text entry widget should appear. In the current version, it should not normally be used.

pos

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

...

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 text entry box 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.

References

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

See Also

rp.control

Examples

if (interactive()) {
   plotf <- function(panel) {
      with(panel, {
		 pars   <- as.numeric(pars)
         xgrid <- seq(0.1, max(c(pars[3], 5), na.rm = TRUE), length = 50)
         dgrid <- df(xgrid, pars[1], pars[2])
         plot(xgrid, dgrid, type = "l", col = "blue", lwd = 3)
         if (!is.na(pars[3])) {
            lines(rep(pars[3], 2), c(0, 0.95 * max(dgrid)), lty = 2, col = "red")
            text(pars[3], max(dgrid), as.character(pars[3]), col = "red")
            }
         })
      panel
      }

   panel <- rp.control(pars = c(5, 10, NA))
   rp.textentry(panel, pars, plotf, labels = c("df1", "df2", "observed"),
          initval = c(10, 5, 3))
   rp.do(panel, plotf)
   }

[Package rpanel version 1.0-6 Index]