[R] apply block of if statements with menu function

rl at openmailbox.org rl at openmailbox.org
Thu Sep 18 16:34:35 CEST 2014


On 2014-09-16 12:35, PIKAL Petr wrote:
> 
> So if result of menu is 0 (you did not choose anything) you can either
> stay with 0, then switch does not return anything or add 1 and let
> evaluate something meaningful specified in second and following
> positions of switch command.
> 

Thanks for your explanation, which completed my understanding! :) For 
the benefit of other novices, below is an example to demonstrate how 
'switch' and 'menu' can be used:

switch(menu(c(1,2),graphics=FALSE,title='select something'), 
{(seq(1:10))}, {(rnorm(20))})

However, how to make the option '0 to exit' to appear in the command 
terminal?



More information about the R-help mailing list