2
I have a line of code that asks for a number requested from the user like this:
menu(c('1','2','3'), title='Escolha um número:')
But it is part of a program that uses this requested number in functions further ahead.
When I run the line of code separately it works well, when running in block it reads each line of code as answer to that question and therefore gives error.
I’ve tried to:
scan("stdin", character(), n=1)
and
file("stdin")
But nothing works.
Thank you for your reply, but it is still a mistake. I wrote a file with the menu function, and then in the complete file where I have the rest of the source code("filename.R") but still R continues to take each line of code as an answer to the question of the menu function
– Rita
@Rita This minimal example I put works on your computer?
– Carlos Cinelli
Yes, this example works @Carlos Cinelli
– Rita
And when I run the "source" function alone in my code it works fine too. The problem is that this function is part of a complete program and when I use "Run all", then the code takes each line of code as a response and gives error
– Rita
@Rita, I don’t understand, but are you running "run all" or "source"? Run all won’t work anyway. Try creating a minimal example that reproduces the problem and put it here.
– Carlos Cinelli
Thank you @Carlos Cinelli. I already managed to solve the problem, as the choice I want was only between three numbers, to use the menu function and run the program with "run all", just add in the menu function "Graphics=TRUE"
– Rita