User Menus under MS Windows (Rgui)

Enables users to add, delete and program menus for the Rgui in MS Windows.

winMenuAddItem(menuname, itemname, action)
winMenuDelItem(menuname, itemname)

a character string naming a menu.


a character string naming a menu item on an existing menu.


a character string describing the action when that menu is selected, or "enable" or "disable".


User menus are added to the right of existing menus, and items are added at the bottom of the menu.

By default the action character string is treated as R input, being echoed on the command line and parsed and executed as usual.

If the menuname parameter of winMenuAddItem does not already exist, it will be created automatically.

Normally new submenus and menu items are added to the main console menu. They may be added elsewhere using the following special names:


The console menu (the default)


The console popup menu


The menu for graphics window <n>


The popup menu for graphics window <n>

Specifying an existing item in winMenuAddItem enables the action to be changed.

Submenus can be specified by separating the elements in menuname by slashes: as a consequence menu names may not contain slashes.

If the action is specified as "none" no action is taken: this can be useful to reserve items for future expansion.

The function winMenuNames can be used to find out what menus have been created by the user and returns a vector of the existing menu names.

The winMenuItems function will take the name of a menu and return the items that exist in that menu. The return value is a named vector where the names correspond to the names of the items and the values of the vector are the corresponding actions.

The winMenuDel function will delete a menu and all of its items and submenus. winMenuDelItem just deletes one menu item.

The total path to an item (menu string plus item string) cannot exceed 1000 bytes, and the menu string cannot exceed 500 bytes.


NULL, invisibly. If an error occurs, an informative error message will be given.


These functions are only available on Windows and only when using the Rgui, hence not in ESS nor RStudio.

See Also


  • winMenuAdd
  • winMenuAddItem
  • winMenuDel
  • winMenuDelItem
  • winMenuNames
  • winMenuItems
library(utils) # NOT RUN { winMenuAdd("Testit") winMenuAddItem("Testit", "one", "aaaa") winMenuAddItem("Testit", "two", "bbbb") winMenuAdd("Testit/extras") winMenuAddItem("Testit", "-", "") winMenuAddItem("Testit", "two", "disable") winMenuAddItem("Testit", "three", "cccc") winMenuAddItem("Testit/extras", "one more", "ddd") winMenuAddItem("Testit/extras", "and another", "eee") winMenuAdd("$ConsolePopup/Testit") winMenuAddItem("$ConsolePopup/Testit", "six", "fff") winMenuNames() winMenuItems("Testit") # }
Documentation reproduced from package utils, version 3.6.2, License: Part of R 3.6.2

Community examples

Looks like there are no examples yet.