switch(EXPRESSION, ...)
If the first argument is not character, it is coerced to integer; if it is in the range 1 to nargs()-1, then the corresponding argument from the ... is evaluated and returned as the value of switch.
switch(dist, cauchy=rcauchy(1), logistic=rlogis(1), norm=rnorm(1))x <- 2 switch(x, 2+2, print("this one is chosen"), { y <- exp(5); z <- sin(2.1)})
switch(as.character(answer), yes=, YES=1, no=, NO=2, 3)