R-调试:通过循环逐行

Sen*_*enf 5 rstudio

我试图找到一种通过R studio进行调试的方法,但是我发现的所有解决方案都无法真正起作用。

1.)CTRL + enter:有效,但不会循环的每次迭代,而只能循环一次。
2.)添加“ browser()”的操作到那时就停止了,但是我不能一行又一行地去(“ n”和“ F10”都不起作用吗?

知道可能是什么问题吗?

小智 2

Put the code/script inside a function:

function_to_debug <- function(data){ 
     a = 2+3 
     return(a)
}
Run Code Online (Sandbox Code Playgroud)

Then run this in R console:

debug(function_to_debug)
Run Code Online (Sandbox Code Playgroud)

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