我有以下代码,它会引发错误并使用以下命令写入所有帧的转储dump.frames()
as 提议 e. G。通过哈德利·威克姆 http://adv-r.had.co.nz/Exceptions-Debugging.html:
a <- -1
b <- "Hello world!"
bad.function <- function(value)
{
log(value) # the log function may cause an error or warning depending on the value
}
tryCatch( {
a.local.value <- 42
bad.function(a)
bad.function(b)
},
error = function(e)
{
dump.frames(to.file = TRUE)
})
当我重新启动 R 会话并加载转储以通过以下方式调试问题时
load(file = "last.dump.rda")
debugger(last.dump)
我在框架中的任何地方都找不到我的变量(a,b,a.local.value)或我的函数“bad.function”。
这使得垃圾场对我来说几乎毫无价值。
我必须做什么才能看到我的所有变量和函数事后分析?
的输出debugger
is:
> load(file = "last.dump.rda")
> debugger(last.dump)
Message: non-numeric argument to mathematical functionAvailable environments had calls:
1: tryCatch({
a.local.value <- 42
bad.function(a)
bad.function(b)
2: tryCatchList(expr, classes, parentenv, handlers)
3: tryCatchOne(expr, names, parentenv, handlers[[1]])
4: value[[3]](cond)
Enter an environment number, or 0 to exit
Selection:
PS:我使用 R3.3.2 和 RStudio 进行调试。