[R] Supplying function inputs interactively

2010-09-11 Thread Christofer Bogaso
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

Re: [R] Supplying function inputs interactively

2010-09-11 Thread Peng, C
Have you tried scan()?: y=scan() 1: 2 2: Read 1 item y [1] 2 -- View this message in context: http://r.789695.n4.nabble.com/Supplying-function-inputs-interactively-tp2536003p2536004.html Sent from the R help mailing list archive at Nabble.com.

Re: [R] Supplying function inputs interactively

2010-09-11 Thread Gabor Grothendieck
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

Re: [R] Supplying function inputs interactively

2010-09-11 Thread Peng, C
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()