AlainD AlainD - 1 month ago 28
R Question

RStudio console stuck - how to reset?

Using Version 0.98.11013. Say I'm testing the following code in my script:

for (num in 1:5)
{
# Print numbers from 1 to the loop variable
print(1:num)
}


As I step over each line (using CTRL+R), I get the following output in the Console:

> for (num in 1:5)
+ {
+ # Print numbers from 1 to the loop variable
+ print(1:num)
+ }
[1] 1
[1] 1 2
[1] 1 2 3
[1] 1 2 3 4
[1] 1 2 3 4 5
>


Now, say I've made an error in my code and forgotten the closing brace
}
:

for (num in 1:5)
{
# Print numbers from 1 to the loop variable
print(1:num)

randomArray <- c(1:10)
# ...and the next line of the R script


Now the Console shows a
+
symbol for every line because it is looking for a closing brace. Someone new to R or RStudio may not be aware of this. Nothing I do gets output working again except closing and re-opening RStudio.

Is there a way to force the RStudio (or the R interpreter) Console to "reset"?

Answer

Try click in the Console and then press the keyboard button ESC.

Comments