Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

R- debug: line by line through a loop

Tags:

rstudio

I try to find a way to debug through R studio, however all the solutions I can find do not really work.

1.) CTRL+enter: works but does not go through every iteration of the loop but only once.
2.) Adding "browser()" stops at that point but I am not able to go from there line by line (neither "n" nor "F10" works?

Any idea what the issue could be?

like image 730
Senf Avatar asked Sep 17 '15 13:09

Senf


1 Answers

Put the code/script inside a function:

function_to_debug <- function(data){ 
     a = 2+3 
     return(a)
}

Then run this in R console:

debug(function_to_debug)

The debugger starts and you can step through each line of the function.

like image 64
Bikash Pandey Avatar answered Oct 03 '22 12:10

Bikash Pandey