r - Switch statement with readline and handling error messages of different class types based on user input -


i want ask user select of options 1 4 , use switch statement transfer flow accordingly. have followed this

how use switch statement in r functions?

interactive() num1 <-readline("select 1 of options") num <- noquote(num1) switch(num,  1={   cat('you have selected option 1') }, 2={   print('you have selected option 2')     }, 3={   #option 3   print('you have selected option 3')     }, 4={   #option 4   print('you have selected option 4')     }, {    print('dah make mind,look @ options again') } ) 

the thing not working when pass string or number readline switch. removed quotes , checked again still doesn't work.

i saved file , running source("file_name.r") want build interactive environment, collect variables user , perform different tasks based on options selected user.

how can make work?


Comments

Popular posts from this blog

c++ - OpenCV Error: Assertion failed <scn == 3 ::scn == 4> in unknown function, -

php - render data via PDO::FETCH_FUNC vs loop -

The canvas has been tainted by cross-origin data in chrome only -