在 R studio 中逐行调试
问题描述:
有没有办法在R studio环境中逐行调试代码??
Is there a way to debug the code line by line in R studio environment ??
我知道有断点,下一步,继续等调试.但我正在寻找像 Visual Studio 中那样的逐行调试选项.
I know there are breakpoints, Next, continue etc to debug. But I am looking for a line by line debug option like the one in Visual Studio.
谢谢
答
debug
包可能就是您想要的.如果您通过此包进行调试,则会打开一个额外的窗口,其中显示您的代码,然后您可以结合 RStudio 逐行调试.
The debug
package is probably what you want. If you are debugging via this package an extra window opens in which your code is displayed and then you can debug line by line in combination with RStudio.
有关如何使用 debug
包进行调试,请参见下面的示例代码:
See below example code for how to debug with the debug
package:
install.packages("debug")
library(debug)
fun <- function(x) {
y <- x + 1
z <- y + 1
return(z)
}
mtrace(fun)
fun(2)