warnings dan metode cetaknya mencetak variabel last.warning dalam bentuk yang menyenangkan.
warnings(…)<p></p><p># S3 method for warnings
summary(object, …)</p><p># S3 method for warnings
print(x, tags,
header = ngettext(n, "Warning message:\n", "Warning messages:\n"),
…)
# S3 method for summary.warnings
print(x, …)</p>
| Parameter | Deskripsi |
|---|---|
… |
arguments to be passed to cat (for warnings()). |
object |
a "warnings" object as returned by warnings(). |
x |
a "warnings" or "summary.warnings" object. |
tags |
if not missing, a character vector of the same length as x, to “label” the messages. Defaults to paste0(seq_len(n), ": ") for \(n \ge 2\) where n <- length(x). |
header |
a character string cat()ed before the messages are printed. |
# NOT RUN {
## NB this example is intended to be pasted in,
## rather than run by example()
ow <- options("warn")
for(w in -1:1) {
options(warn = w); cat("\n warn =", w, "\n")
for(i in 1:3) { cat(i,"..\n"); m <- matrix(1:7, 3,4) }
cat("--=--=--\n")
}
## at the end prints all three warnings, from the 'option(warn = 0)' above
options(ow) # reset to previous, typically 'warn = 0'
tail(warnings(), 2) # see the last two warnings only (via '[' method)
## Often the most useful way to look at many warnings:
summary(warnings())
# }
# NOT RUN {
op <- options(nwarnings = 10000) ## <- get "full statistics"
x <- 1:36; for(n in 1:13) for(m in 1:12) A <- matrix(x, n,m) # There were 105 warnings ...
summary(warnings())
options(op) # revert to previous (keeping 50 messages by default)
# }