Examples for 'base::warnings'


Print Warning Messages

Aliases: warnings last.warning print.warnings [.warnings c.warnings duplicated.warnings unique.warnings summary.warnings print.summary.warnings

Keywords: programming error

### ** Examples

## 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")
}
 warn = -1 
1 ..
2 ..
3 ..
--=--=--

 warn = 0 
1 ..
Warning in matrix(1:7, 3, 4): data length [7] is not a sub-multiple or multiple
of the number of rows [3]
2 ..
Warning in matrix(1:7, 3, 4): data length [7] is not a sub-multiple or multiple
of the number of rows [3]
3 ..
Warning in matrix(1:7, 3, 4): data length [7] is not a sub-multiple or multiple
of the number of rows [3]
--=--=--

 warn = 1 
1 ..
Warning in matrix(1:7, 3, 4): data length [7] is not a sub-multiple or multiple
of the number of rows [3]
2 ..
Warning in matrix(1:7, 3, 4): data length [7] is not a sub-multiple or multiple
of the number of rows [3]
3 ..
Warning in matrix(1:7, 3, 4): data length [7] is not a sub-multiple or multiple
of the number of rows [3]
--=--=--
## 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)
NULL
## Often the most useful way to look at many warnings:
summary(warnings())
Length  Class   Mode 
     0   NULL   NULL 
## Don't show: 
ww <- warnings()
uw <- unique(ww)
sw <- summary(ww)
stopifnot(identical(c(ww[1], ww[3]), ww[c(1, 3)]),
          length(uw) == 1, nchar(names(uw)) > 10,
          length(sw) == 1, attr(sw, "counts") == 3)
Error: length(uw) == 1 is not TRUE
## End(Don't show)
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 ...
Warning in matrix(x, n, m): data length differs from size of matrix: [36 != 1 x
1]
Warning in matrix(x, n, m): data length differs from size of matrix: [36 != 1 x
2]
Warning in matrix(x, n, m): data length differs from size of matrix: [36 != 1 x
3]
Warning in matrix(x, n, m): data length differs from size of matrix: [36 != 1 x
4]
Warning in matrix(x, n, m): data length [36] is not a sub-multiple or multiple
of the number of columns [5]
Warning in matrix(x, n, m): data length differs from size of matrix: [36 != 1 x
6]
Warning in matrix(x, n, m): data length [36] is not a sub-multiple or multiple
of the number of columns [7]
Warning in matrix(x, n, m): data length [36] is not a sub-multiple or multiple
of the number of columns [8]
Warning in matrix(x, n, m): data length differs from size of matrix: [36 != 1 x
9]
Warning in matrix(x, n, m): data length [36] is not a sub-multiple or multiple
of the number of columns [10]
Warning in matrix(x, n, m): data length [36] is not a sub-multiple or multiple
of the number of columns [11]
Warning in matrix(x, n, m): data length differs from size of matrix: [36 != 1 x
12]
Warning in matrix(x, n, m): data length differs from size of matrix: [36 != 2 x
1]
Warning in matrix(x, n, m): data length differs from size of matrix: [36 != 2 x
2]
Warning in matrix(x, n, m): data length differs from size of matrix: [36 != 2 x
3]
Warning in matrix(x, n, m): data length differs from size of matrix: [36 != 2 x
4]
Warning in matrix(x, n, m): data length [36] is not a sub-multiple or multiple
of the number of columns [5]
Warning in matrix(x, n, m): data length differs from size of matrix: [36 != 2 x
6]
Warning in matrix(x, n, m): data length [36] is not a sub-multiple or multiple
of the number of columns [7]
Warning in matrix(x, n, m): data length [36] is not a sub-multiple or multiple
of the number of columns [8]
Warning in matrix(x, n, m): data length differs from size of matrix: [36 != 2 x
9]
Warning in matrix(x, n, m): data length [36] is not a sub-multiple or multiple
of the number of columns [10]
Warning in matrix(x, n, m): data length [36] is not a sub-multiple or multiple
of the number of columns [11]
Warning in matrix(x, n, m): data length differs from size of matrix: [36 != 2 x
12]
Warning in matrix(x, n, m): data length differs from size of matrix: [36 != 3 x
1]
Warning in matrix(x, n, m): data length differs from size of matrix: [36 != 3 x
2]
Warning in matrix(x, n, m): data length differs from size of matrix: [36 != 3 x
3]
Warning in matrix(x, n, m): data length differs from size of matrix: [36 != 3 x
4]
Warning in matrix(x, n, m): data length [36] is not a sub-multiple or multiple
of the number of columns [5]
Warning in matrix(x, n, m): data length differs from size of matrix: [36 != 3 x
6]
Warning in matrix(x, n, m): data length [36] is not a sub-multiple or multiple
of the number of columns [7]
Warning in matrix(x, n, m): data length [36] is not a sub-multiple or multiple
of the number of columns [8]
Warning in matrix(x, n, m): data length differs from size of matrix: [36 != 3 x
9]
Warning in matrix(x, n, m): data length [36] is not a sub-multiple or multiple
of the number of columns [10]
Warning in matrix(x, n, m): data length [36] is not a sub-multiple or multiple
of the number of columns [11]
Warning in matrix(x, n, m): data length differs from size of matrix: [36 != 4 x
1]
Warning in matrix(x, n, m): data length differs from size of matrix: [36 != 4 x
2]
Warning in matrix(x, n, m): data length differs from size of matrix: [36 != 4 x
3]
Warning in matrix(x, n, m): data length differs from size of matrix: [36 != 4 x
4]
Warning in matrix(x, n, m): data length [36] is not a sub-multiple or multiple
of the number of columns [5]
Warning in matrix(x, n, m): data length differs from size of matrix: [36 != 4 x
6]
Warning in matrix(x, n, m): data length [36] is not a sub-multiple or multiple
of the number of columns [7]
Warning in matrix(x, n, m): data length [36] is not a sub-multiple or multiple
of the number of columns [8]
Warning in matrix(x, n, m): data length [36] is not a sub-multiple or multiple
of the number of columns [10]
Warning in matrix(x, n, m): data length [36] is not a sub-multiple or multiple
of the number of columns [11]
Warning in matrix(x, n, m): data length differs from size of matrix: [36 != 4 x
12]
Warning in matrix(x, n, m): data length [36] is not a sub-multiple or multiple
of the number of rows [5]

Warning in matrix(x, n, m): data length [36] is not a sub-multiple or multiple
of the number of rows [5]

Warning in matrix(x, n, m): data length [36] is not a sub-multiple or multiple
of the number of rows [5]

Warning in matrix(x, n, m): data length [36] is not a sub-multiple or multiple
of the number of rows [5]

Warning in matrix(x, n, m): data length [36] is not a sub-multiple or multiple
of the number of rows [5]

Warning in matrix(x, n, m): data length [36] is not a sub-multiple or multiple
of the number of rows [5]

Warning in matrix(x, n, m): data length [36] is not a sub-multiple or multiple
of the number of rows [5]

Warning in matrix(x, n, m): data length [36] is not a sub-multiple or multiple
of the number of rows [5]

Warning in matrix(x, n, m): data length [36] is not a sub-multiple or multiple
of the number of rows [5]

Warning in matrix(x, n, m): data length [36] is not a sub-multiple or multiple
of the number of rows [5]

Warning in matrix(x, n, m): data length [36] is not a sub-multiple or multiple
of the number of rows [5]

Warning in matrix(x, n, m): data length [36] is not a sub-multiple or multiple
of the number of rows [5]
Warning in matrix(x, n, m): data length differs from size of matrix: [36 != 6 x
1]
Warning in matrix(x, n, m): data length differs from size of matrix: [36 != 6 x
2]
Warning in matrix(x, n, m): data length differs from size of matrix: [36 != 6 x
3]
Warning in matrix(x, n, m): data length differs from size of matrix: [36 != 6 x
4]
Warning in matrix(x, n, m): data length [36] is not a sub-multiple or multiple
of the number of columns [5]
Warning in matrix(x, n, m): data length [36] is not a sub-multiple or multiple
of the number of columns [7]
Warning in matrix(x, n, m): data length [36] is not a sub-multiple or multiple
of the number of columns [8]
Warning in matrix(x, n, m): data length differs from size of matrix: [36 != 6 x
9]
Warning in matrix(x, n, m): data length [36] is not a sub-multiple or multiple
of the number of columns [10]
Warning in matrix(x, n, m): data length [36] is not a sub-multiple or multiple
of the number of columns [11]
Warning in matrix(x, n, m): data length [36] is not a sub-multiple or multiple
of the number of rows [7]

Warning in matrix(x, n, m): data length [36] is not a sub-multiple or multiple
of the number of rows [7]

Warning in matrix(x, n, m): data length [36] is not a sub-multiple or multiple
of the number of rows [7]

Warning in matrix(x, n, m): data length [36] is not a sub-multiple or multiple
of the number of rows [7]

Warning in matrix(x, n, m): data length [36] is not a sub-multiple or multiple
of the number of rows [7]

Warning in matrix(x, n, m): data length [36] is not a sub-multiple or multiple
of the number of rows [7]

Warning in matrix(x, n, m): data length [36] is not a sub-multiple or multiple
of the number of rows [7]

Warning in matrix(x, n, m): data length [36] is not a sub-multiple or multiple
of the number of rows [7]

Warning in matrix(x, n, m): data length [36] is not a sub-multiple or multiple
of the number of rows [7]

Warning in matrix(x, n, m): data length [36] is not a sub-multiple or multiple
of the number of rows [7]

Warning in matrix(x, n, m): data length [36] is not a sub-multiple or multiple
of the number of rows [7]

Warning in matrix(x, n, m): data length [36] is not a sub-multiple or multiple
of the number of rows [7]
Warning in matrix(x, n, m): data length [36] is not a sub-multiple or multiple
of the number of rows [8]

Warning in matrix(x, n, m): data length [36] is not a sub-multiple or multiple
of the number of rows [8]

Warning in matrix(x, n, m): data length [36] is not a sub-multiple or multiple
of the number of rows [8]

Warning in matrix(x, n, m): data length [36] is not a sub-multiple or multiple
of the number of rows [8]

Warning in matrix(x, n, m): data length [36] is not a sub-multiple or multiple
of the number of rows [8]

Warning in matrix(x, n, m): data length [36] is not a sub-multiple or multiple
of the number of rows [8]

Warning in matrix(x, n, m): data length [36] is not a sub-multiple or multiple
of the number of rows [8]

Warning in matrix(x, n, m): data length [36] is not a sub-multiple or multiple
of the number of rows [8]

Warning in matrix(x, n, m): data length [36] is not a sub-multiple or multiple
of the number of rows [8]

Warning in matrix(x, n, m): data length [36] is not a sub-multiple or multiple
of the number of rows [8]

Warning in matrix(x, n, m): data length [36] is not a sub-multiple or multiple
of the number of rows [8]
Warning in matrix(x, n, m): data length differs from size of matrix: [36 != 9 x
1]
Warning in matrix(x, n, m): data length differs from size of matrix: [36 != 9 x
2]
Warning in matrix(x, n, m): data length differs from size of matrix: [36 != 9 x
3]
Warning in matrix(x, n, m): data length [36] is not a sub-multiple or multiple
of the number of columns [5]
Warning in matrix(x, n, m): data length differs from size of matrix: [36 != 9 x
6]
Warning in matrix(x, n, m): data length [36] is not a sub-multiple or multiple
of the number of columns [7]
Warning in matrix(x, n, m): data length differs from size of matrix: [36 != 9 x
9]
Warning in matrix(x, n, m): data length [36] is not a sub-multiple or multiple
of the number of columns [10]
Warning in matrix(x, n, m): data length [36] is not a sub-multiple or multiple
of the number of columns [11]
Warning in matrix(x, n, m): data length [36] is not a sub-multiple or multiple
of the number of rows [10]

Warning in matrix(x, n, m): data length [36] is not a sub-multiple or multiple
of the number of rows [10]

Warning in matrix(x, n, m): data length [36] is not a sub-multiple or multiple
of the number of rows [10]

Warning in matrix(x, n, m): data length [36] is not a sub-multiple or multiple
of the number of rows [10]

Warning in matrix(x, n, m): data length [36] is not a sub-multiple or multiple
of the number of rows [10]

Warning in matrix(x, n, m): data length [36] is not a sub-multiple or multiple
of the number of rows [10]

Warning in matrix(x, n, m): data length [36] is not a sub-multiple or multiple
of the number of rows [10]

Warning in matrix(x, n, m): data length [36] is not a sub-multiple or multiple
of the number of rows [10]

Warning in matrix(x, n, m): data length [36] is not a sub-multiple or multiple
of the number of rows [10]

Warning in matrix(x, n, m): data length [36] is not a sub-multiple or multiple
of the number of rows [10]

Warning in matrix(x, n, m): data length [36] is not a sub-multiple or multiple
of the number of rows [10]

Warning in matrix(x, n, m): data length [36] is not a sub-multiple or multiple
of the number of rows [10]
Warning in matrix(x, n, m): data length [36] is not a sub-multiple or multiple
of the number of rows [11]

Warning in matrix(x, n, m): data length [36] is not a sub-multiple or multiple
of the number of rows [11]

Warning in matrix(x, n, m): data length [36] is not a sub-multiple or multiple
of the number of rows [11]

Warning in matrix(x, n, m): data length [36] is not a sub-multiple or multiple
of the number of rows [11]

Warning in matrix(x, n, m): data length [36] is not a sub-multiple or multiple
of the number of rows [11]

Warning in matrix(x, n, m): data length [36] is not a sub-multiple or multiple
of the number of rows [11]

Warning in matrix(x, n, m): data length [36] is not a sub-multiple or multiple
of the number of rows [11]

Warning in matrix(x, n, m): data length [36] is not a sub-multiple or multiple
of the number of rows [11]

Warning in matrix(x, n, m): data length [36] is not a sub-multiple or multiple
of the number of rows [11]

Warning in matrix(x, n, m): data length [36] is not a sub-multiple or multiple
of the number of rows [11]

Warning in matrix(x, n, m): data length [36] is not a sub-multiple or multiple
of the number of rows [11]

Warning in matrix(x, n, m): data length [36] is not a sub-multiple or multiple
of the number of rows [11]
Warning in matrix(x, n, m): data length differs from size of matrix: [36 != 12
x 1]
Warning in matrix(x, n, m): data length differs from size of matrix: [36 != 12
x 2]
Warning in matrix(x, n, m): data length differs from size of matrix: [36 != 12
x 4]
Warning in matrix(x, n, m): data length [36] is not a sub-multiple or multiple
of the number of columns [5]
Warning in matrix(x, n, m): data length [36] is not a sub-multiple or multiple
of the number of columns [7]
Warning in matrix(x, n, m): data length [36] is not a sub-multiple or multiple
of the number of columns [8]
Warning in matrix(x, n, m): data length [36] is not a sub-multiple or multiple
of the number of columns [10]
Warning in matrix(x, n, m): data length [36] is not a sub-multiple or multiple
of the number of columns [11]
Warning in matrix(x, n, m): data length [36] is not a sub-multiple or multiple
of the number of rows [13]

Warning in matrix(x, n, m): data length [36] is not a sub-multiple or multiple
of the number of rows [13]

Warning in matrix(x, n, m): data length [36] is not a sub-multiple or multiple
of the number of rows [13]

Warning in matrix(x, n, m): data length [36] is not a sub-multiple or multiple
of the number of rows [13]

Warning in matrix(x, n, m): data length [36] is not a sub-multiple or multiple
of the number of rows [13]

Warning in matrix(x, n, m): data length [36] is not a sub-multiple or multiple
of the number of rows [13]

Warning in matrix(x, n, m): data length [36] is not a sub-multiple or multiple
of the number of rows [13]

Warning in matrix(x, n, m): data length [36] is not a sub-multiple or multiple
of the number of rows [13]

Warning in matrix(x, n, m): data length [36] is not a sub-multiple or multiple
of the number of rows [13]

Warning in matrix(x, n, m): data length [36] is not a sub-multiple or multiple
of the number of rows [13]

Warning in matrix(x, n, m): data length [36] is not a sub-multiple or multiple
of the number of rows [13]

Warning in matrix(x, n, m): data length [36] is not a sub-multiple or multiple
of the number of rows [13]
summary(warnings())
Length  Class   Mode 
     0   NULL   NULL 
options(op) # revert to previous (keeping 50 messages by default)

[Package base version 4.2.3 Index]