[R] apply block of if statements with menu function

rl at openmailbox.org rl at openmailbox.org
Mon Sep 15 10:52:50 CEST 2014


Subscribers,

apply block of if statements with menu function
Subscribers,

For a menu:

menu(c('a','b','c','d'))

How to create a function that will apply to specific menu choice 
objects? For example:

object1<-function (menuifchoices) {
menu1<-menu(c('a','b','c','d'))
	if (menu1==1)
	...
	menu1a<-menu...
		if (menu1a==1)
		...
	menu2a<-menu...
		if (menu2a==1)
		...
menu2
	<-menu(c('a','b','c','d'))
	if (menu1==2)
	...
}

The request action is that a user can select a menu option that will 
activate a series of "multiple choice" questions, results in "menu1" 
being activated without menu2 being activated. If someone could direct 
to the relevant terminology, thank you.

Separate question; for a menu:

menu(c('a','b','c','d'))

1: a
2: b
3: c
4: d

Selection: 1
[1] 1

is it possible to change behaviour so that result of the selection is 
not the integer, but the original menu choice:

Selection: 1
[1] a



More information about the R-help mailing list