任何R ide都支持条件断点吗?

时间:2021-04-16 17:02:35

Which, if any, R IDEs (e.g. StatET, Revolution R, RStudio, ESS, NppToR, others) support conditional breakpoints?

如果有,R ide(例如StatET、Revolution R、RStudio、ESS、NppToR等)支持条件断点吗?

This is available via bp in the debug package, or via an additional bit of code that invokes browser() based on a condition. However, it can be more efficient to be able to toggle a particular line # and quickly enter a conditional breakpoint for that particular line, without having additional code or console activities.

这可以通过调试包中的bp获得,也可以通过基于条件调用browser()的附加代码。但是,可以更有效地切换特定的行#并快速地为特定的行输入条件断点,而不需要额外的代码或控制台活动。


Note 1. I've searched a bit for these, and it seems that conditional breakpoints are not available in RStudio, and I think the same may be true for StatET. There appears to be support in ESS (see this page), though I'm not yet familiar with ess-tracebug and whether it's easy to use. It also seems that this works only for older versions of ESS; I'm not yet familiar with functionality for more recent versions.

注1。我搜索了一些,似乎RStudio中没有条件断点,我认为StatET也是如此。ESS中似乎有支持(请参阅本页面),尽管我还不熟悉ESS tracebug,也不知道它是否易于使用。这似乎只适用于旧版本的ESS;我还不熟悉最新版本的功能。


Update 1. I'm selecting an answer (the only one - Andrie's). The question was answerable regarding whether any IDE supports conditional breakpoints, and, fortunately, Andrie has demonstrated that there exists a solution. I remain interested in any other IDEs that support this, though Eclipse is good enough for now. (At the moment, I prefer Rstudio, but this is already in their feature request list.) If anyone has expertise in ESS and can demonstrate that functionality, I'm sure it will benefit others who happen upon this question.

更新1。我在选择一个答案(唯一的一个——Andrie)。关于任何IDE是否支持条件断点的问题是可以回答的,幸运的是,Andrie已经证明了存在一个解决方案。我仍然对其他支持这个的ide感兴趣,尽管Eclipse现在已经足够好了。(目前,我更喜欢Rstudio,但这已经在他们的特性请求列表中了。)如果有人在ESS方面有专业知识,并且能够演示该功能,我相信这将会使遇到这个问题的其他人受益。

3 个解决方案

#1


9  

Yes, this is possible with Eclipse + StatET 2.0 in R 2.14-1.

是的,在r2.14 -1中使用Eclipse + StatET 2.0是可能的。

Eclipse supports conditional debugging, and StatET 2.0 supports visual debugging (as long as you have a fairly recent version of R.)

Eclipse支持条件调试,StatET 2.0支持可视化调试(只要您有一个较新的r版本)

Assuming you know your way around Eclipse, do the following:

假设您知道如何使用Eclipse,请执行以下操作:

  • Start a debugging session in Eclipse (i.e. invoke a Debug configuration, not a Run configuration)
  • 在Eclipse中启动调试会话(例如,调用调试配置,而不是运行配置)
  • Set a breakpoint in your code
  • 在代码中设置断点
  • Open a Debug perspective
  • 打开一个Debug透视图
  • Run your code
  • 运行代码

With the debug perspective open, you will have a pane that contains tabs for Variables / Breakpoints. In the breakpoints tab, select your breakpoint, then click the Conditional / Expression tickbox and enter your condition.

打开debug透视图,您将有一个包含变量/断点的选项卡。在breakpoints选项卡中,选择您的断点,然后单击条件/表达式tickbox并输入条件。

任何R ide都支持条件断点吗?

In searching for this answer, I found the following pages helpful:

在寻找这个答案时,我发现以下几页很有帮助:

#2


0  

The preview release of RStudio v0.98 has this feature: http://www.rstudio.com/ide/docs/debugging/overview

RStudio v0.98的预览版有如下特性:http://www.rstudio.com/ide/docs/debugging/overview

Only drawback is your function should be in the same file with your main code if you want to set a breakpoint in your function.

唯一的缺点是,如果您想在函数中设置断点,那么您的函数应该在与主代码相同的文件中。

#3


0  

There is a little trick to set a conditional breakpoint in rstudio:

在rstudio中设置条件断点有一个小技巧:

for(i in 1:10){
  if(i==5){
    print("set the breakpoint at this line by shift+f9")
  }
  i*i
}

The only drawback is you need to add some extra code

唯一的缺点是您需要添加一些额外的代码

#1


9  

Yes, this is possible with Eclipse + StatET 2.0 in R 2.14-1.

是的,在r2.14 -1中使用Eclipse + StatET 2.0是可能的。

Eclipse supports conditional debugging, and StatET 2.0 supports visual debugging (as long as you have a fairly recent version of R.)

Eclipse支持条件调试,StatET 2.0支持可视化调试(只要您有一个较新的r版本)

Assuming you know your way around Eclipse, do the following:

假设您知道如何使用Eclipse,请执行以下操作:

  • Start a debugging session in Eclipse (i.e. invoke a Debug configuration, not a Run configuration)
  • 在Eclipse中启动调试会话(例如,调用调试配置,而不是运行配置)
  • Set a breakpoint in your code
  • 在代码中设置断点
  • Open a Debug perspective
  • 打开一个Debug透视图
  • Run your code
  • 运行代码

With the debug perspective open, you will have a pane that contains tabs for Variables / Breakpoints. In the breakpoints tab, select your breakpoint, then click the Conditional / Expression tickbox and enter your condition.

打开debug透视图,您将有一个包含变量/断点的选项卡。在breakpoints选项卡中,选择您的断点,然后单击条件/表达式tickbox并输入条件。

任何R ide都支持条件断点吗?

In searching for this answer, I found the following pages helpful:

在寻找这个答案时,我发现以下几页很有帮助:

#2


0  

The preview release of RStudio v0.98 has this feature: http://www.rstudio.com/ide/docs/debugging/overview

RStudio v0.98的预览版有如下特性:http://www.rstudio.com/ide/docs/debugging/overview

Only drawback is your function should be in the same file with your main code if you want to set a breakpoint in your function.

唯一的缺点是,如果您想在函数中设置断点,那么您的函数应该在与主代码相同的文件中。

#3


0  

There is a little trick to set a conditional breakpoint in rstudio:

在rstudio中设置条件断点有一个小技巧:

for(i in 1:10){
  if(i==5){
    print("set the breakpoint at this line by shift+f9")
  }
  i*i
}

The only drawback is you need to add some extra code

唯一的缺点是您需要添加一些额外的代码