On Sat, Sep 11, 2010 at 7:17 PM, Christofer Bogaso <bogaso.christo...@gmail.com> wrote: > 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) > } >
Try this: ysquared <- function(y) { if (missing(y)) y <- as.numeric(readline("Enter y: ")) y*y } ysquared() -- Statistics & Software Consulting GKX Group, GKX Associates Inc. tel: 1-877-GKX-GROUP email: ggrothendieck at gmail.com ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.