[R] Supplying function inputs interactively
Peng, C
cpeng.usm at gmail.com
Sun Sep 12 01:41:11 CEST 2010
Is this what you would expect to have. Definitely you can make this function
more elegant:
fn1 <- function(x = 10) {
cat("Please type the option number to get your Y value:\n\n")
cat(" 1. Y = 1.\n
2. Y = 2.\n
3. Use the default y.\n
4. Choose my own value for y.\n\n")
opt=scan()
if (opt==3) y <-0
else if (opt==4) {
cat("Please type your Y value:\n\n")
y=scan()
}
else y = opt
return(x*y)
}
--
View this message in context: http://r.789695.n4.nabble.com/Supplying-function-inputs-interactively-tp2536003p2536012.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list