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
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.
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
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()
4 matches
Mail list logo