I assume that one could do.call()call an anonymous function:
tmp <- switch("b",
a = print("foo"),
b = do.call(function() paste("I want to evaluate this one!"),
list()),
stop("say what now?")
)
eg:.
> tmp
[1] "I want to evaluate this one!"
Edit
A simpler version is higher:
tmp <- switch("b",
a = print("foo"),
b = (function() paste("I want to evaluate this one!"))(),
stop("say what now?")
)
, , ().
:
foo <- function() paste("I want to evaluate this one!")
tmp <- switch("b",
a = print("foo"),
b = foo(),
stop("say what now?")
)
:
> tmp
[1] "I want to evaluate this one!"
, foo() , .