menu

0th

Percentile

Menu Interaction Function

menu presents the user with a menu of choices labelled from 1 to the number of choices. To exit without choosing an item one can select 0.

Keywords
utilities, programming
Usage
menu(choices, graphics = FALSE, title = NULL)
Arguments
choices
a character vector of choices
graphics
a logical indicating whether a graphics menu should be used if available.
title
a character string to be used as the title of the menu. NULL is also accepted.
Details

If graphics = TRUE and a windowing system is available (Windows, macOS or X11 via Tcl/Tk) a listbox widget is used, otherwise a text menu. It is an error to use menu in a non-interactive session. Ten or fewer items will be displayed in a single column, more in multiple columns if possible within the current display width. No title is displayed if title is NULL or "".

Value

The number corresponding to the selected item, or 0 if no choice was made.

References

Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988) The New S Language. Wadsworth & Brooks/Cole.

See Also

select.list, which is used to implement the graphical menu, and allows multiple selections.

Aliases
  • menu
Examples
library(utils) ## Not run: ------------------------------------ # switch(menu(c("List letters", "List LETTERS")) + 1, # cat("Nothing done\n"), letters, LETTERS) ## ---------------------------------------------
Documentation reproduced from package utils, version 3.3.2, License: Part of R 3.3.2

Community examples

Looks like there are no examples yet.