【问题标题】:How to debug S4 class in RStudio如何在 RStudio 中调试 S4 类
【发布时间】:2018-08-08 15:40:21
【问题描述】:

这是我的 S4 类,它保存在单独的文件中,目前在 RStudio 中打开:

setClass(
  Class = 'some_cls', 
  slots = c(some_slot = 'numeric'),
)


setGeneric("some_method", function(self)
  standardGeneric("some_method"))
setMethod("some_method", 
          signature(self = "some_cls"), 
          function(self) {
            self@some_slot <- 5
            self
          }
)

在我执行的另一个文件中:

some_obj <- new('some_cls')
some_obj <- some_method(some_obj)

我尝试调试some_method,就像我通常在 RStudio 中所做的那样。我将点放在self@some_slot &lt;- 5 行旁边,在我的 RStudio 中我单击右上角的Source,但代码执行并没有在断点处停止。我做错了什么?

【问题讨论】:

    标签: r class debugging rstudio s4


    【解决方案1】:

    这看起来像是 RStudio 中的一个错误;您可能想向他们报告。 R 中的底层基础架构在处理像您这样的情况时没有问题。

    例如,如果第一个文件名为test.R,并且您希望断点位于第 12 行,则运行

    setBreakpoint("test.R#12")
    

    当你到达那里时,执行将中断。

    【讨论】:

      猜你喜欢
      • 2017-04-16
      • 2015-10-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-07-16
      • 2014-02-28
      • 2015-11-19
      • 1970-01-01
      相关资源
      最近更新 更多