我一直在閱讀關於如何使用tryCatch
的SO的答案。我真的不明白c
變量來自哪裏。'e'或'c'來自R的tryCatch
例如(通過http://adv-r.had.co.nz/Exceptions-Debugging.html#condition-handling)
show_condition <- function(code) {
tryCatch(code,
error = function(c) "error",
warning = function(c) "warning",
message = function(c) "message"
)
}
show_condition(stop("!"))
#> [1] "error"
show_condition(warning("?!"))
#> [1] "warning"
show_condition(message("?"))
#> [1] "message"
# If no condition is captured, tryCatch returns the
# value of the input
show_condition(10)
#> [1] 10
c
是一個系統變量? Elsewhere其他人似乎使用e
在其位置?
'C'是意義和時間花費打字之間的平衡。我使用'e'來處理錯誤,'w'使用警告。 – 2014-10-07 13:49:38