Learn R Programming

svDialogs (version 0.9-52)

dlgList: A list selection dialog box

Description

Select one or several items in a list.

Usage

dlgList(choices, preselect = NULL, multiple = FALSE, title = NULL,
    ..., gui = .GUI)
   
## These should not be called directly
## S3 method for class 'gui':
dlgList(choices, preselect = NULL, multiple = FALSE, title = NULL,
    \dots, gui = .GUI)
## S3 method for class 'textCLI':
dlgList(choices, preselect = NULL, multiple = FALSE, title = NULL,
    \dots, gui = .GUI)
## S3 method for class 'nativeGUI':
dlgList(choices, preselect = NULL, multiple = FALSE, title = NULL,
    \dots, gui = .GUI)

Arguments

choices
the list of items. It is coerced to character strings.
preselect
a list of preselections, or NULL (then, the first element is selected in the list). Preselections not in choices are tolerated (and disregarded, of course).
multiple
is it a multiple selection dialog box?
title
the title of the dialog box, or NULL.
...
pass further arguments to methods.
gui
the 'gui' object concerned by this dialog box.

Value

  • The modified 'gui' object is returned invisibly. A list with selected items, or a character vector of length 0 if the dialog box was cancelled is available from gui$res (see examples).

concept

GUI API dialog boxes

Examples

Run this code
## Select a month
res <- dlgList(month.name, multiple = TRUE)$res
if (!length(res)) {
  cat("You cancelled the choice
")
} else {
  cat("You selected:
")
  print(res)
}

Run the code above in your browser using DataLab