9.3 跟踪/不跟踪

Keywords:

Next: ,Previous: debug/undebug,Up: Debugging

9.3 跟踪/不跟踪

另外一种监控 R 行为的方法是 trace 机制。具体用法是以你想跟踪的函数名字作为参数调用 trace。这里的名字一般不需要用引号括住,但也一些函数名字需要用引号引住以防止语法错误。

当对一个函数调用 trace 时,每次该函数求值,它的调用都会被打印出来。该机制可以通过调用以函数作为参数的 untrace 去除。

     > get("[<-")

     .Primitive("[<-")

     > trace("[<-")

     > x <- 1:10

     > x[3] <- 4

     trace: "[<-"(*tmp*, 3, value = 4)

Hits:Loading...

special topic