Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Annoying RStudio Behavior in debugging

Tags:

r

rstudio

When I am in debug mode in a function and uses "CTRL + Enter" on an object/variable, R takes me back on line 1 of the function and prints the object variable to the console. Is this a bug or an expected behavior?

Another bug in debug mode: - If there is a print(variable1) somewhere in the function, R will not only print to the console variable1 but also the remaining function code that comes after "print(variable1)"

Are there any ways of avoiding those behaviors of R Studio?

Thanks,

like image 542
Fredkho Avatar asked Nov 09 '22 15:11

Fredkho


1 Answers

This may be worth reporting to rstudio directly as it may be a bug that was left over from a change of behavior in debug mode. I looked through the browser help file and didn't come across this behavior.

An rstudio article from April 2016 on debugging here, states that

Simply pressing Enter at the console will execute the current statement and move on to the next one. This is a convenient way to step through statements quickly.

Note that most of the commands listed in this section directly match with the behavior of browser.

However, I've been reading Hadley's Advanced R recently and came across the following in section 3.2.2:

There are two other slightly less useful commands that aren’t available in the toolbar:
* Enter: repeats the previous command. I find this too easy to activate accidentally, so I turn it off using options(browserNLdisabled = TRUE).
...

Since Advanced R was published in 2014, my thinking is that this is legacy behavior that you should report to the makers of rstudio, complete with a reproducible example.

like image 112
lmo Avatar answered Nov 15 '22 07:11

lmo