use*_*377 9 debugging error-handling r
我有一个大约1400行的R脚本.我最近开始收到以下错误消息.我可以通过突出显示并使用ctrl-R来运行脚本,但我无法在调试模式下运行脚本.有关如何找到错误的任何建议?
> debugSource('~/working/R/h60_maintenance/do_mega_analysis.R')
Error in fBody[[i]] : subscript out of bounds
> options(error=recover)
> debugSource('~/working/R/h60_maintenance/do_mega_analysis.R')
Error in fBody[[i]] : subscript out of bounds
Enter a frame number, or 0 to exit
1: debugSource("~/working/R/h60_maintenance/do_mega_analysis.R")
2: (function (fileName, encoding, breaklines)
{
env <- new.env(parent = emptyenv())
env$fun <-
3: suppressWarnings(.rs.setFunctionBreakpoints("fun", env, lapply(steps, function(step) {
step$at
}
4: withCallingHandlers(expr, warning = function(w) invokeRestart("muffleWarning"))
5: .rs.setFunctionBreakpoints("fun", env, lapply(steps, function(step) {
step$at
}))
6: suppressMessages(trace(what = functionName, where = envir, at = lapply(strsplit(as.character(steps
7: withCallingHandlers(expr, message = function(c) invokeRestart("muffleMessage"))
8: trace(what = functionName, where = envir, at = lapply(strsplit(as.character(steps), ","), as.numer
9: eval.parent(call)
10: eval(expr, p)
11: eval(expr, envir, enclos)
12: methods::.TraceWithMethods(what = functionName, where = <environment>, at = lapply(strsplit(as.cha
13: new(traceClass, def = if (doEdit) def else original, tracer = tracer, exit = exit, at = at, print
14: initialize(value, ...)
15: initialize(value, ...)
16: .initTraceable(.Object, ...)
17: .makeTracedFunction(def, tracer, exit, at, print, doEdit)
Run Code Online (Sandbox Code Playgroud)
该错误可能与以下行有关,因为这些行与选项10:eval(expr,p)相关联.
imds_rollup <- imds_detail_dt[,{
## if there's just one row in the group of ID's, return nothing
list(
count_every_fault = .N,
max_ci_value = max(CI.Value),
max_rotor_turn_time_air_sec = max(Rotor.Turn.Time...In.Air..s.),
max_rotor_turn_time_ground_sec = max(Rotor.Turn.Time...On.Ground..s.)
)}, by = c("BUNO","fileEventIndex")]
setkeyv(imds_rollup,c("BUNO","fileEventIndex"))
imds_rollup$max_ci_value <- NULL # max_ci_value has all NA
Run Code Online (Sandbox Code Playgroud)
Jam*_*orn 36
我也有这个问题.它是由无效断点引起的:当您设置断点,然后修改将断点移动到注释或空行的代码时会发生这种情况.
只需清除所有断点并重新获取源.
| 归档时间: |
|
| 查看次数: |
5939 次 |
| 最近记录: |