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
Post a Comment