[R] Supplying function inputs interactively

Christofer Bogaso bogaso.christofer at gmail.com
Sun Sep 12 01:17:27 CEST 2010


Dear all, I am looking for some procedure to send inputs to a function
interactively. Here is an example:

fn1 <- function(x = 10) {
y <- 0
# ask user whether he wants to put some other value for "y"
# R will show 2 options: 1. y = 2
#                                  2. y = 3
# user will choose either options 1 or 2
# once user is done, function will over-write the existing value of y,
with say, option 2. Therefore current value of y is 2. Then R will
continue calculation
return(x*y)
}

Here obviously I can put "y" as the 2nd input of fn1(), however I want
to do so interactively.

Can friends here direct me how to do that?

Thanks,



More information about the R-help mailing list