Running 'allocArray.R' [0s]
  Running 'allocMatrix.R' [172s]
  Running 'allocVector.R' [0s]
  Running 'anyMissing.R' [171s]
  Running 'anyMissing_subset.R' [179s]
  Running 'benchmark.R' [15s]
  Running 'binCounts.R' [166s]
  Running 'binCounts_subset.R' [0s]
  Running 'binMeans,binCounts.R' [0s]
  Running 'binMeans,binCounts_subset.R' [0s]
  Running 'count.R' [156s]
  Running 'count_subset.R' [0s]
  Running 'diff2.R' [173s]
  Running 'diff2_subset.R' [0s]
  Running 'indexByRow.R' [0s]
  Running 'logSumExp.R' [0s]
  Running 'logSumExp_subset.R' [153s]
  Running 'mean2.R' [156s]
  Running 'mean2_subset.R' [152s]
  Running 'product.R' [176s]
  Running 'product_subset.R' [0s]
  Running 'psortKM.R' [0s]
  Running 'rowAllAnys.R' [165s]
  Running 'rowAllAnys_subset.R' [9s]
  Running 'rowAvgsPerColSet.R' [0s]
  Running 'rowAvgsPerColSet_subset.R' [165s]
  Running 'rowCollapse.R' [0s]
  Running 'rowCollapse_subset.R' [0s]
  Running 'rowCounts.R' [159s]
  Running 'rowCounts_subset.R' [4s]
  Running 'rowCumMinMaxs.R' [1s]
  Running 'rowCumMinMaxs_subset.R' [3s]
  Running 'rowCumprods.R' [1s]
  Running 'rowCumprods_subset.R' [154s]
  Running 'rowCumsums.R' [149s]
  Running 'rowCumsums_subset.R' [1s]
  Running 'rowDiffs.R' [142s]
  Running 'rowDiffs_subset.R' [3s]
  Running 'rowIQRs.R' [1s]
  Running 'rowIQRs_subset.R' [2s]
  Running 'rowLogSumExps.R' [162s]
  Running 'rowLogSumExps_subset.R' [2s]
  Running 'rowMads.R' [1s]
  Running 'rowMads_subset.R' [162s]
  Running 'rowMeans2.R' [1s]
  Running 'rowMeans2_subset.R' [1s]
  Running 'rowMedians.R' [1s]
  Running 'rowMedians_subset.R' [1s]
  Running 'rowOrderStats.R' [170s]
  Running 'rowOrderStats_subset.R' [2s]
  Running 'rowProds.R' [0s]
  Running 'rowProds_subset.R' [158s]
  Running 'rowQuantiles.R' [185s]
  Running 'rowQuantiles_subset.R' [2s]
  Running 'rowRanges.R' [150s]
  Running 'rowRanges_subset.R' [164s]
  Running 'rowRanks.R' [155s]
  Running 'rowRanks_subset.R' [2s]
  Running 'rowSds.R' [155s]
  Running 'rowSds_subset.R' [155s]
  Running 'rowSums2.R' [1s]
  Running 'rowSums2_subset.R' [1s]
  Running 'rowTabulates.R' [166s]
  Running 'rowTabulates_subset.R' [145s]
  Running 'rowVarDiffs.R' [1s]
  Running 'rowVarDiffs_mad,iqr_subset.R' [7s]
  Running 'rowVarDiffs_var,sd_subset.R' [6s]
  Running 'rowVars.R' [156s]
  Running 'rowVars_subset.R' [154s]
  Running 'rowWeightedMeans.R' [158s]
  Running 'rowWeightedMeans_subset.R' [172s]
  Running 'rowWeightedMedians.R' [0s]
  Running 'rowWeightedMedians_subset.R' [2s]
  Running 'rowWeightedVars.R' [0s]
  Running 'rowWeightedVars_subset.R' [3s]
  Running 'signTabulate.R' [174s]
  Running 'signTabulate_subset.R' [151s]
  Running 'sum2.R' [1s]
  Running 'sum2_subset.R' [177s]
  Running 'validateIndices.R' [164s]
  Running 'varDiff_etal.R' [0s]
  Running 'varDiff_etal_subset.R' [0s]
  Running 'weightedMean.R' [0s]
  Running 'weightedMean_subset.R' [149s]
  Running 'weightedMedian.R' [160s]
  Running 'weightedMedian_subset.R' [168s]
  Running 'weightedVar.R' [149s]
  Running 'weightedVar_etal.R' [0s]
  Running 'weightedVar_etal_subset.R' [148s]
  Running 'x_OP_y.R' [1s]
  Running 'x_OP_y_subset.R' [165s]
  Running 'zzz.package-unload.R' [170s]
Running the tests in 'tests/allocMatrix.R' failed.
Complete output:
  > library("matrixStats")
  > 
  > allocMatrix_R <- function(nrow, ncol, value = NA) {
  +   matrix(data = value, nrow = nrow, ncol = ncol)
  + }
  > 
  > values <- list(
  +   -1L, 0L, +1L, NA_integer_, .Machine$integer.max,
  +   -1, 0, +1, NA_real_, NaN, -Inf, +Inf,
  +   .Machine$double.xmin, .Machine$double.xmax,
  +   .Machine$double.eps, .Machine$double.neg.eps,
  +   FALSE, TRUE, NA
  + )
  > 
  > nrow <- 2L
  > ncol <- 3L
  > for (value in values) {
  +   x0 <- allocMatrix_R(nrow, ncol, value = value)
  +   x <- allocMatrix(nrow, ncol, value = value)
  +   if (!identical(x, x0)) {
  +     str(list(nrow = nrow, ncol = ncol, value = value, x = x, x0 = x0))
  +     stopifnot(identical(x, x0))
  +   }
  + }
  > 
  > proc.time()
     user  system elapsed 
     0.23    0.04    0.28 
Running the tests in 'tests/anyMissing.R' failed.
Complete output:
  > library("matrixStats")
  > 
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > # Setup
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > data <- data.frame(
  +   logical   = c(TRUE, FALSE, TRUE),
  +   integer   = 1:3,
  +   double    = seq(from = 1.0, to = 3.0, by = 1.0),
  +   complex   = seq(from = 1.0, to = 3.0, by = 1.0) + 1.0i,
  +   character = letters[1:3],
  +   stringsAsFactors = FALSE
  + )
  > 
  > modes <- names(data)
  > 
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > # Special cases
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > cat("NULL...\n")
  NULL...
  > stopifnot(identical(anyMissing(NULL), FALSE))
  > cat("NULL...done\n")
  NULL...done
  > 
  > cat("raw...\n")
  raw...
  > stopifnot(identical(anyMissing(as.raw(0:2)), FALSE))
  > cat("raw...done\n")
  raw...done
  > 
  > cat("list(NULL)...\n")
  list(NULL)...
  > stopifnot(identical(anyMissing(list(NULL)), FALSE))
  > cat("list(NULL)...done\n")
  list(NULL)...done
  > 
  > 
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > # Scalars, vectors, and matrices of various modes
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > for (mode in modes) {
  +   cat(sprintf("Mode: %s...\n", mode))
  +   values <- data[[mode]]
  + 
  +   # Scalars
  +   cat(" scalar\n")
  +   x <- values[1L]
  +   print(x)
  +   stopifnot(identical(anyMissing(x), FALSE))
  +   is.na(x) <- TRUE
  +   print(x)
  +   stopifnot(identical(anyMissing(x), TRUE))
  + 
  +   # Vectors
  +   cat(" vector\n")
  +   x <- values
  +   print(x)
  +   stopifnot(identical(anyMissing(x), FALSE))
  +   is.na(x)[2L] <- TRUE
  +   print(x)
  +   stopifnot(identical(anyMissing(x), TRUE))
  + 
  +   # Matrices
  +   cat(" matrix\n")
  +   x <- matrix(c(values, values), ncol = 2L)
  +   print(x)
  +   stopifnot(identical(anyMissing(x), FALSE))
  +   is.na(x)[2L] <- TRUE
  +   print(x)
  +   stopifnot(identical(anyMissing(x), TRUE))
  + 
  +   cat(sprintf("Mode: %s...done\n", mode))
  + } # for (mode ...)
  Mode: logical...
   scalar
  [1] TRUE
  [1] NA
   vector
  [1]  TRUE FALSE  TRUE
  [1] TRUE   NA TRUE
   matrix
        [,1]  [,2]
  [1,]  TRUE  TRUE
  [2,] FALSE FALSE
  [3,]  TRUE  TRUE
       [,1]  [,2]
  [1,] TRUE  TRUE
  [2,]   NA FALSE
  [3,] TRUE  TRUE
  Mode: logical...done
  Mode: integer...
   scalar
  [1] 1
  [1] NA
   vector
  [1] 1 2 3
  [1]  1 NA  3
   matrix
       [,1] [,2]
  [1,]    1    1
  [2,]    2    2
  [3,]    3    3
       [,1] [,2]
  [1,]    1    1
  [2,]   NA    2
  [3,]    3    3
  Mode: integer...done
  Mode: double...
   scalar
  [1] 1
  [1] NA
   vector
  [1] 1 2 3
  [1]  1 NA  3
   matrix
       [,1] [,2]
  [1,]    1    1
  [2,]    2    2
  [3,]    3    3
       [,1] [,2]
  [1,]    1    1
  [2,]   NA    2
  [3,]    3    3
  Mode: double...done
  Mode: complex...
   scalar
  [1] 1+1i
  [1] NA
   vector
  [1] 1+1i 2+1i 3+1i
  [1] 1+1i   NA 3+1i
   matrix
       [,1] [,2]
  [1,] 1+1i 1+1i
  [2,] 2+1i 2+1i
  [3,] 3+1i 3+1i
       [,1] [,2]
  [1,] 1+1i 1+1i
  [2,]   NA 2+1i
  [3,] 3+1i 3+1i
  Mode: complex...done
  Mode: character...
   scalar
  [1] "a"
  [1] NA
   vector
  [1] "a" "b" "c"
  [1] "a" NA  "c"
   matrix
       [,1] [,2]
  [1,] "a"  "a" 
  [2,] "b"  "b" 
  [3,] "c"  "c" 
       [,1] [,2]
  [1,] "a"  "a" 
  [2,] NA   "b" 
  [3,] "c"  "c" 
  Mode: character...done
  > 
  > 
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > # Data frames
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > cat("data.frame...\n")
  data.frame...
  > x <- data
  > stopifnot(identical(anyMissing(x), FALSE))
  > for (mode in modes) {
  +   x <- data
  +   is.na(x[[mode]])[2L] <- TRUE
  +   print(x)
  +   stopifnot(identical(anyMissing(x), TRUE))
  + } # for (mode ...)
    logical integer double complex character
  1    TRUE       1      1    1+1i         a
  2      NA       2      2    2+1i         b
  3    TRUE       3      3    3+1i         c
    logical integer double complex character
  1    TRUE       1      1    1+1i         a
  2   FALSE      NA      2    2+1i         b
  3    TRUE       3      3    3+1i         c
    logical integer double complex character
  1    TRUE       1      1    1+1i         a
  2   FALSE       2     NA    2+1i         b
  3    TRUE       3      3    3+1i         c
    logical integer double complex character
  1    TRUE       1      1    1+1i         a
  2   FALSE       2      2      NA         b
  3    TRUE       3      3    3+1i         c
    logical integer double complex character
  1    TRUE       1      1    1+1i         a
  2   FALSE       2      2    2+1i      <NA>
  3    TRUE       3      3    3+1i         c
  > cat("data.frame...done\n")
  data.frame...done
  > 
  > 
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > # Lists
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > cat("list...\n")
  list...
  > x <- as.list(data)
  > stopifnot(identical(anyMissing(x), FALSE))
  > for (mode in modes) {
  +   x <- as.list(data)
  +   is.na(x[[mode]])[2L] <- TRUE
  +   print(x)
  +   stopifnot(identical(anyMissing(x), TRUE))
  + } # for (mode ...)
  $logical
  [1] TRUE   NA TRUE
  
  $integer
  [1] 1 2 3
  
  $double
  [1] 1 2 3
  
  $complex
  [1] 1+1i 2+1i 3+1i
  
  $character
  [1] "a" "b" "c"
  
  $logical
  [1]  TRUE FALSE  TRUE
  
  $integer
  [1]  1 NA  3
  
  $double
  [1] 1 2 3
  
  $complex
  [1] 1+1i 2+1i 3+1i
  
  $character
  [1] "a" "b" "c"
  
  $logical
  [1]  TRUE FALSE  TRUE
  
  $integer
  [1] 1 2 3
  
  $double
  [1]  1 NA  3
  
  $complex
  [1] 1+1i 2+1i 3+1i
  
  $character
  [1] "a" "b" "c"
  
  $logical
  [1]  TRUE FALSE  TRUE
  
  $integer
  [1] 1 2 3
  
  $double
  [1] 1 2 3
  
  $complex
  [1] 1+1i   NA 3+1i
  
  $character
  [1] "a" "b" "c"
  
  $logical
  [1]  TRUE FALSE  TRUE
  
  $integer
  [1] 1 2 3
  
  $double
  [1] 1 2 3
  
  $complex
  [1] 1+1i 2+1i 3+1i
  
  $character
  [1] "a" NA  "c"
  
  > cat("list...done\n")
  list...done
  > 
  > proc.time()
     user  system elapsed 
     0.26    0.04    0.28 
Running the tests in 'tests/anyMissing_subset.R' failed.
Complete output:
  > library("matrixStats")
  > 
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > # Subsetted tests
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > source("utils/validateIndicesFramework.R")
  > x <- runif(4, min = -3, max = 3)
  > x[2] <- NA
  > for (mode in c("integer", "numeric")) {
  +   storage.mode(x) <- mode
  +   for (idxs in index_cases) {
  +     validateIndicesTestVector(x, idxs,
  +                               ftest = anyMissing, fsure = function(x, ...) {
  +         anyValue(x, value = NA)
  +     })
  +   }
  + }
  > 
  > proc.time()
     user  system elapsed 
     0.20    0.10    0.28 
Running the tests in 'tests/binCounts.R' failed.
Complete output:
  > library("matrixStats")
  > library("stats")
  > 
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > # Local functions
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > binCounts_hist <- function(x, bx, right = FALSE, ...) {
  +   n0 <- graphics::hist(x, breaks = bx, right = right,
  +                        include.lowest = TRUE, plot = FALSE)$counts
  + }
  > 
  > 
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > # Non-sorted and sorted positions
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > nx <- 1000L  # Number of data points
  > nb <- 200L   # Number of bins
  > 
  > # Uniformely distributed bins
  > bx <- seq(from = 0, to = 1, length.out = nb + 1L)
  > bx <- c(-1, bx, 2)
  > 
  > # Sample data points
  > set.seed(0xBEEF)
  > x <- runif(nx, min = 0, max = 1)
  > 
  > for (kk in 1:2) {
  +   n0 <- binCounts_hist(x, bx = bx)
  +   n1 <- binCounts(x, bx = bx)
  +   # Sanity check
  +   stopifnot(identical(n1, n0))
  + 
  +   # Check reversed
  +   n1r <- rev(binCounts(-x, bx = rev(-bx), right = TRUE))
  +   stopifnot(identical(n1r, n1))
  + 
  +   # Retry with a sorted vector
  +   x <- sort(x)
  + } # for (kk in 1:2)
  > 
  > 
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > # Missing values
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > x <- 1:40
  > x[20] <- NA_integer_
  > nx <- length(x)
  > 
  > # Bins
  > bx <- c(0.5, 50.5, 100.5, 150.5, 200.5)
  > 
  > y_smooth0 <- binCounts_hist(x, bx = bx)
  > y_smooth <- binCounts(x, bx = bx)
  > # Sanity check
  > stopifnot(all.equal(y_smooth, y_smooth0))
  > 
  > 
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > # Border cases
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > x <- 1:10
  > bx <- min(x) - c(10, 1)
  > y_smooth <- binCounts(x, bx = bx)
  > stopifnot(all.equal(y_smooth, 0L))
  > bx <- range(x)
  > y_smooth <- binCounts(x, bx = bx)
  > stopifnot(all.equal(y_smooth, length(x) - 1L))
  > bx <- max(x) + c(1, 10)
  > y_smooth <- binCounts(x, bx = bx)
  > stopifnot(all.equal(y_smooth, 0L))
  > 
  > # Every second empty
  > x <- 1:10
  > bx <- rep(x, each = 2L)
  > y_smooth <- binCounts(x, bx = bx)
  > stopifnot(all.equal(y_smooth, rep(c(0L, 1L), length.out = length(bx) - 1L)))
  > ## NOTE: binCounts_hist() does not give the same last bin count
  > 
  > 
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > # Exception handling
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > # Zero bin bounderies (invalid bin definition)
  > bx <- double(0L)
  > res <- try(y_smooth <- binCounts(1:10, bx = bx), silent = TRUE)
  > stopifnot(inherits(res, "try-error"))
  > 
  > # One bin boundery (invalid bin definition)
  > bx <- double(1L)
  > res <- try(y_smooth <- binCounts(1:10, bx = bx), silent = TRUE)
  > stopifnot(inherits(res, "try-error"))
  > 
  > proc.time()
     user  system elapsed 
     0.20    0.06    0.26 
Running the tests in 'tests/count.R' failed.
Complete output:
  > library("matrixStats")
  > 
  > count_R <- function(x, value = TRUE, na.rm = FALSE, ...) {
  +   if (is.na(value)) {
  +     counts <- sum(is.na(x))
  +   } else {
  +     counts <- sum(x == value, na.rm = na.rm)
  +   }
  +   as.integer(counts)
  + }
  > 
  > 
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > # Data type: integer and numeric
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > for (mode in c("integer", "double")) {
  +   x <- runif(20 * 5, min = -3, max = 3)
  +   x[sample.int(length(x), size = 7)] <- 0
  +   storage.mode(x) <- mode
  + 
  +   for (na.rm in c(FALSE, TRUE)) {
  +     # Count zeros
  +     n0 <- count_R(x, value = 0, na.rm = na.rm)
  +     n1 <- count(x, value = 0, na.rm = na.rm)
  +     stopifnot(identical(n1, n0))
  +     all <- allValue(x, value = 0, na.rm = na.rm)
  +     any <- anyValue(x, value = 0, na.rm = na.rm)
  + 
  +     # Count NAs
  +     n0 <- count_R(x, value = NA, na.rm = na.rm)
  +     n1 <- count(x, value = NA, na.rm = na.rm)
  +     stopifnot(identical(n1, n0))
  +     all <- allValue(x, value = NA, na.rm = na.rm)
  +     any <- anyValue(x, value = NA, na.rm = na.rm)
  + 
  +     if (mode == "integer") {
  +       ux <- unique(as.vector(x))
  +       n0 <- n1 <- integer(length(x))
  +       for (value in ux) {
  +         n0 <- n0 + count_R(x, value = value, na.rm = na.rm)
  +         n1 <- n1 + count(x, value = value, na.rm = na.rm)
  +         stopifnot(identical(n1, n0))
  +       }
  +       stopifnot(all(n0 == ncol(x)))
  +     } # if (mode == "integer")
  + 
  +   } # for (na.rm ...)
  + } # for (mode ...)
  > 
  > # All NAs
  > na_list <- list(NA_integer_, NA_real_, NaN)
  > for (na_value in na_list) {
  +   x <- rep(na_value, times = 10L)
  +   for (na.rm in c(FALSE, TRUE)) {
  +     n0 <- count_R(x, na.rm = na.rm)
  +     n1 <- count(x, na.rm = na.rm)
  +     stopifnot(identical(n1, n0))
  + 
  +     # Count NAs
  +     n0 <- count_R(x, value = NA, na.rm = na.rm)
  +     n1 <- count(x, value = NA, na.rm = na.rm)
  +     stopifnot(identical(n1, n0))
  +     any <- anyValue(x, value = NA, na.rm = na.rm)
  +     all <- allValue(x, value = NA, na.rm = na.rm)
  +     stopifnot(any)
  +     stopifnot(all)
  +   }
  + } # for (na_value ...)
  > 
  > 
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > # Data type: logical
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > x <- logical(length = 10L)
  > x[3:7] <- TRUE
  > 
  > # Row/column counts
  > for (na.rm in c(FALSE, TRUE)) {
  +   n0 <- count_R(x, na.rm = na.rm)
  +   n1 <- count(x, na.rm = na.rm)
  +   stopifnot(identical(n1, n0))
  + 
  +   n_true <- count(x, value = TRUE, na.rm = na.rm)
  +   n_false <- count(x, value = FALSE, na.rm = na.rm)
  +   stopifnot(n_true + n_false == ncol(x))
  + 
  +   # Count NAs
  +   n0 <- count_R(x, value = NA, na.rm = na.rm)
  +   n1 <- count(x, value = NA, na.rm = na.rm)
  +   stopifnot(identical(n1, n0))
  + }
  > 
  > proc.time()
     user  system elapsed 
     0.23    0.04    0.26 
Running the tests in 'tests/diff2.R' failed.
Complete output:
  > library("matrixStats")
  > 
  > diff2_R <- function(..., useNames = NA){
  +   res <- diff(...)
  +   if (is.na(useNames) || !useNames) names(res) <- NULL
  +   res
  + }
  > 
  > set.seed(0x42)
  > 
  > for (mode in c("integer", "double")) {
  +   x <- rnorm(10, sd = 5)
  +   storage.mode(x) <- mode
  +   str(x)
  + 
  +   for (has_na in c(FALSE, TRUE)) {
  +     for (setNames in c(TRUE, FALSE)) {
  +       for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) {
  +         if (has_na) {
  +           x[sample(1:10, size = 3)] <- NA
  +         }
  +         if (setNames) {
  +           names(x) <- LETTERS[1:10]
  +         }
  +         for (l in 1:3) {
  +           for (d in 1:4) {
  +             cat(sprintf("%s: NAs = %s, lag = %d, differences = %d, setNames = %d, useNames = %d\n",
  +                         mode, has_na, l, d, setNames, useNames))
  +             y0 <- diff2_R(x, lag = l, differences = d, useNames = useNames)
  +             str(y0)
  +             y1 <- diff2(x, lag = l, differences = d, useNames = useNames)
  +             str(y1)
  +             stopifnot(identical(y1, y0))
  +           }
  +         }  
  +       }
  +     }
  +   } # for (has_na ...)
  + }
   int [1:10] 11 1 2 0 -1 -3 -3 6 0 0
  integer: NAs = FALSE, lag = 1, differences = 1, setNames = 1, useNames = 1
   Named int [1:9] -10 1 -2 -1 -2 0 9 -6 0
   - attr(*, "names")= chr [1:9] "B" "C" "D" "E" ...
   Named int [1:9] -10 1 -2 -1 -2 0 9 -6 0
   - attr(*, "names")= chr [1:9] "B" "C" "D" "E" ...
  integer: NAs = FALSE, lag = 1, differences = 2, setNames = 1, useNames = 1
   Named int [1:8] 11 -3 1 -1 2 9 -15 6
   - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ...
   Named int [1:8] 11 -3 1 -1 2 9 -15 6
   - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ...
  integer: NAs = FALSE, lag = 1, differences = 3, setNames = 1, useNames = 1
   Named int [1:7] -14 4 -2 3 7 -24 21
   - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ...
   Named int [1:7] -14 4 -2 3 7 -24 21
   - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ...
  integer: NAs = FALSE, lag = 1, differences = 4, setNames = 1, useNames = 1
   Named int [1:6] 18 -6 5 4 -31 45
   - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ...
   Named int [1:6] 18 -6 5 4 -31 45
   - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ...
  integer: NAs = FALSE, lag = 2, differences = 1, setNames = 1, useNames = 1
   Named int [1:8] -9 -1 -3 -3 -2 9 3 -6
   - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ...
   Named int [1:8] -9 -1 -3 -3 -2 9 3 -6
   - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ...
  integer: NAs = FALSE, lag = 2, differences = 2, setNames = 1, useNames = 1
   Named int [1:6] 6 -2 1 12 5 -15
   - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ...
   Named int [1:6] 6 -2 1 12 5 -15
   - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ...
  integer: NAs = FALSE, lag = 2, differences = 3, setNames = 1, useNames = 1
   Named int [1:4] -5 14 4 -27
   - attr(*, "names")= chr [1:4] "G" "H" "I" "J"
   Named int [1:4] -5 14 4 -27
   - attr(*, "names")= chr [1:4] "G" "H" "I" "J"
  integer: NAs = FALSE, lag = 2, differences = 4, setNames = 1, useNames = 1
   Named int [1:2] 9 -41
   - attr(*, "names")= chr [1:2] "I" "J"
   Named int [1:2] 9 -41
   - attr(*, "names")= chr [1:2] "I" "J"
  integer: NAs = FALSE, lag = 3, differences = 1, setNames = 1, useNames = 1
   Named int [1:7] -11 -2 -5 -3 7 3 3
   - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ...
   Named int [1:7] -11 -2 -5 -3 7 3 3
   - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ...
  integer: NAs = FALSE, lag = 3, differences = 2, setNames = 1, useNames = 1
   Named int [1:4] 8 9 8 6
   - attr(*, "names")= chr [1:4] "G" "H" "I" "J"
   Named int [1:4] 8 9 8 6
   - attr(*, "names")= chr [1:4] "G" "H" "I" "J"
  integer: NAs = FALSE, lag = 3, differences = 3, setNames = 1, useNames = 1
   Named int -2
   - attr(*, "names")= chr "J"
   Named int -2
   - attr(*, "names")= chr "J"
  integer: NAs = FALSE, lag = 3, differences = 4, setNames = 1, useNames = 1
   Named int(0) 
   - attr(*, "names")= chr(0) 
   Named int(0) 
   - attr(*, "names")= chr(0) 
  integer: NAs = FALSE, lag = 1, differences = 1, setNames = 1, useNames = 0
   int [1:9] -10 1 -2 -1 -2 0 9 -6 0
   int [1:9] -10 1 -2 -1 -2 0 9 -6 0
  integer: NAs = FALSE, lag = 1, differences = 2, setNames = 1, useNames = 0
   int [1:8] 11 -3 1 -1 2 9 -15 6
   int [1:8] 11 -3 1 -1 2 9 -15 6
  integer: NAs = FALSE, lag = 1, differences = 3, setNames = 1, useNames = 0
   int [1:7] -14 4 -2 3 7 -24 21
   int [1:7] -14 4 -2 3 7 -24 21
  integer: NAs = FALSE, lag = 1, differences = 4, setNames = 1, useNames = 0
   int [1:6] 18 -6 5 4 -31 45
   int [1:6] 18 -6 5 4 -31 45
  integer: NAs = FALSE, lag = 2, differences = 1, setNames = 1, useNames = 0
   int [1:8] -9 -1 -3 -3 -2 9 3 -6
   int [1:8] -9 -1 -3 -3 -2 9 3 -6
  integer: NAs = FALSE, lag = 2, differences = 2, setNames = 1, useNames = 0
   int [1:6] 6 -2 1 12 5 -15
   int [1:6] 6 -2 1 12 5 -15
  integer: NAs = FALSE, lag = 2, differences = 3, setNames = 1, useNames = 0
   int [1:4] -5 14 4 -27
   int [1:4] -5 14 4 -27
  integer: NAs = FALSE, lag = 2, differences = 4, setNames = 1, useNames = 0
   int [1:2] 9 -41
   int [1:2] 9 -41
  integer: NAs = FALSE, lag = 3, differences = 1, setNames = 1, useNames = 0
   int [1:7] -11 -2 -5 -3 7 3 3
   int [1:7] -11 -2 -5 -3 7 3 3
  integer: NAs = FALSE, lag = 3, differences = 2, setNames = 1, useNames = 0
   int [1:4] 8 9 8 6
   int [1:4] 8 9 8 6
  integer: NAs = FALSE, lag = 3, differences = 3, setNames = 1, useNames = 0
   int -2
   int -2
  integer: NAs = FALSE, lag = 3, differences = 4, setNames = 1, useNames = 0
   int(0) 
   int(0) 
  integer: NAs = FALSE, lag = 1, differences = 1, setNames = 0, useNames = 1
   Named int [1:9] -10 1 -2 -1 -2 0 9 -6 0
   - attr(*, "names")= chr [1:9] "B" "C" "D" "E" ...
   Named int [1:9] -10 1 -2 -1 -2 0 9 -6 0
   - attr(*, "names")= chr [1:9] "B" "C" "D" "E" ...
  integer: NAs = FALSE, lag = 1, differences = 2, setNames = 0, useNames = 1
   Named int [1:8] 11 -3 1 -1 2 9 -15 6
   - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ...
   Named int [1:8] 11 -3 1 -1 2 9 -15 6
   - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ...
  integer: NAs = FALSE, lag = 1, differences = 3, setNames = 0, useNames = 1
   Named int [1:7] -14 4 -2 3 7 -24 21
   - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ...
   Named int [1:7] -14 4 -2 3 7 -24 21
   - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ...
  integer: NAs = FALSE, lag = 1, differences = 4, setNames = 0, useNames = 1
   Named int [1:6] 18 -6 5 4 -31 45
   - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ...
   Named int [1:6] 18 -6 5 4 -31 45
   - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ...
  integer: NAs = FALSE, lag = 2, differences = 1, setNames = 0, useNames = 1
   Named int [1:8] -9 -1 -3 -3 -2 9 3 -6
   - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ...
   Named int [1:8] -9 -1 -3 -3 -2 9 3 -6
   - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ...
  integer: NAs = FALSE, lag = 2, differences = 2, setNames = 0, useNames = 1
   Named int [1:6] 6 -2 1 12 5 -15
   - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ...
   Named int [1:6] 6 -2 1 12 5 -15
   - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ...
  integer: NAs = FALSE, lag = 2, differences = 3, setNames = 0, useNames = 1
   Named int [1:4] -5 14 4 -27
   - attr(*, "names")= chr [1:4] "G" "H" "I" "J"
   Named int [1:4] -5 14 4 -27
   - attr(*, "names")= chr [1:4] "G" "H" "I" "J"
  integer: NAs = FALSE, lag = 2, differences = 4, setNames = 0, useNames = 1
   Named int [1:2] 9 -41
   - attr(*, "names")= chr [1:2] "I" "J"
   Named int [1:2] 9 -41
   - attr(*, "names")= chr [1:2] "I" "J"
  integer: NAs = FALSE, lag = 3, differences = 1, setNames = 0, useNames = 1
   Named int [1:7] -11 -2 -5 -3 7 3 3
   - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ...
   Named int [1:7] -11 -2 -5 -3 7 3 3
   - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ...
  integer: NAs = FALSE, lag = 3, differences = 2, setNames = 0, useNames = 1
   Named int [1:4] 8 9 8 6
   - attr(*, "names")= chr [1:4] "G" "H" "I" "J"
   Named int [1:4] 8 9 8 6
   - attr(*, "names")= chr [1:4] "G" "H" "I" "J"
  integer: NAs = FALSE, lag = 3, differences = 3, setNames = 0, useNames = 1
   Named int -2
   - attr(*, "names")= chr "J"
   Named int -2
   - attr(*, "names")= chr "J"
  integer: NAs = FALSE, lag = 3, differences = 4, setNames = 0, useNames = 1
   Named int(0) 
   - attr(*, "names")= chr(0) 
   Named int(0) 
   - attr(*, "names")= chr(0) 
  integer: NAs = FALSE, lag = 1, differences = 1, setNames = 0, useNames = 0
   int [1:9] -10 1 -2 -1 -2 0 9 -6 0
   int [1:9] -10 1 -2 -1 -2 0 9 -6 0
  integer: NAs = FALSE, lag = 1, differences = 2, setNames = 0, useNames = 0
   int [1:8] 11 -3 1 -1 2 9 -15 6
   int [1:8] 11 -3 1 -1 2 9 -15 6
  integer: NAs = FALSE, lag = 1, differences = 3, setNames = 0, useNames = 0
   int [1:7] -14 4 -2 3 7 -24 21
   int [1:7] -14 4 -2 3 7 -24 21
  integer: NAs = FALSE, lag = 1, differences = 4, setNames = 0, useNames = 0
   int [1:6] 18 -6 5 4 -31 45
   int [1:6] 18 -6 5 4 -31 45
  integer: NAs = FALSE, lag = 2, differences = 1, setNames = 0, useNames = 0
   int [1:8] -9 -1 -3 -3 -2 9 3 -6
   int [1:8] -9 -1 -3 -3 -2 9 3 -6
  integer: NAs = FALSE, lag = 2, differences = 2, setNames = 0, useNames = 0
   int [1:6] 6 -2 1 12 5 -15
   int [1:6] 6 -2 1 12 5 -15
  integer: NAs = FALSE, lag = 2, differences = 3, setNames = 0, useNames = 0
   int [1:4] -5 14 4 -27
   int [1:4] -5 14 4 -27
  integer: NAs = FALSE, lag = 2, differences = 4, setNames = 0, useNames = 0
   int [1:2] 9 -41
   int [1:2] 9 -41
  integer: NAs = FALSE, lag = 3, differences = 1, setNames = 0, useNames = 0
   int [1:7] -11 -2 -5 -3 7 3 3
   int [1:7] -11 -2 -5 -3 7 3 3
  integer: NAs = FALSE, lag = 3, differences = 2, setNames = 0, useNames = 0
   int [1:4] 8 9 8 6
   int [1:4] 8 9 8 6
  integer: NAs = FALSE, lag = 3, differences = 3, setNames = 0, useNames = 0
   int -2
   int -2
  integer: NAs = FALSE, lag = 3, differences = 4, setNames = 0, useNames = 0
   int(0) 
   int(0) 
  integer: NAs = TRUE, lag = 1, differences = 1, setNames = 1, useNames = 1
   Named int [1:9] NA NA NA NA NA 0 9 -6 0
   - attr(*, "names")= chr [1:9] "B" "C" "D" "E" ...
   Named int [1:9] NA NA NA NA NA 0 9 -6 0
   - attr(*, "names")= chr [1:9] "B" "C" "D" "E" ...
  integer: NAs = TRUE, lag = 1, differences = 2, setNames = 1, useNames = 1
   Named int [1:8] NA NA NA NA NA 9 -15 6
   - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ...
   Named int [1:8] NA NA NA NA NA 9 -15 6
   - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ...
  integer: NAs = TRUE, lag = 1, differences = 3, setNames = 1, useNames = 1
   Named int [1:7] NA NA NA NA NA -24 21
   - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ...
   Named int [1:7] NA NA NA NA NA -24 21
   - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ...
  integer: NAs = TRUE, lag = 1, differences = 4, setNames = 1, useNames = 1
   Named int [1:6] NA NA NA NA NA 45
   - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ...
   Named int [1:6] NA NA NA NA NA 45
   - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ...
  integer: NAs = TRUE, lag = 2, differences = 1, setNames = 1, useNames = 1
   Named int [1:8] -9 NA NA NA NA 9 3 -6
   - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ...
   Named int [1:8] -9 NA NA NA NA 9 3 -6
   - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ...
  integer: NAs = TRUE, lag = 2, differences = 2, setNames = 1, useNames = 1
   Named int [1:6] NA NA NA NA NA -15
   - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ...
   Named int [1:6] NA NA NA NA NA -15
   - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ...
  integer: NAs = TRUE, lag = 2, differences = 3, setNames = 1, useNames = 1
   Named int [1:4] NA NA NA NA
   - attr(*, "names")= chr [1:4] "G" "H" "I" "J"
   Named int [1:4] NA NA NA NA
   - attr(*, "names")= chr [1:4] "G" "H" "I" "J"
  integer: NAs = TRUE, lag = 2, differences = 4, setNames = 1, useNames = 1
   Named int [1:2] NA NA
   - attr(*, "names")= chr [1:2] "I" "J"
   Named int [1:2] NA NA
   - attr(*, "names")= chr [1:2] "I" "J"
  integer: NAs = TRUE, lag = 3, differences = 1, setNames = 1, useNames = 1
   Named int [1:7] NA NA -5 NA NA 3 3
   - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ...
   Named int [1:7] NA NA -5 NA NA 3 3
   - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ...
  integer: NAs = TRUE, lag = 3, differences = 2, setNames = 1, useNames = 1
   Named int [1:4] NA NA 8 NA
   - attr(*, "names")= chr [1:4] "G" "H" "I" "J"
   Named int [1:4] NA NA 8 NA
   - attr(*, "names")= chr [1:4] "G" "H" "I" "J"
  integer: NAs = TRUE, lag = 3, differences = 3, setNames = 1, useNames = 1
   Named int NA
   - attr(*, "names")= chr "J"
   Named int NA
   - attr(*, "names")= chr "J"
  integer: NAs = TRUE, lag = 3, differences = 4, setNames = 1, useNames = 1
   Named int(0) 
   - attr(*, "names")= chr(0) 
   Named int(0) 
   - attr(*, "names")= chr(0) 
  integer: NAs = TRUE, lag = 1, differences = 1, setNames = 1, useNames = 0
   int [1:9] NA NA NA NA NA 0 9 NA NA
   int [1:9] NA NA NA NA NA 0 9 NA NA
  integer: NAs = TRUE, lag = 1, differences = 2, setNames = 1, useNames = 0
   int [1:8] NA NA NA NA NA 9 NA NA
   int [1:8] NA NA NA NA NA 9 NA NA
  integer: NAs = TRUE, lag = 1, differences = 3, setNames = 1, useNames = 0
   int [1:7] NA NA NA NA NA NA NA
   int [1:7] NA NA NA NA NA NA NA
  integer: NAs = TRUE, lag = 1, differences = 4, setNames = 1, useNames = 0
   int [1:6] NA NA NA NA NA NA
   int [1:6] NA NA NA NA NA NA
  integer: NAs = TRUE, lag = 2, differences = 1, setNames = 1, useNames = 0
   int [1:8] NA NA NA NA NA 9 NA -6
   int [1:8] NA NA NA NA NA 9 NA -6
  integer: NAs = TRUE, lag = 2, differences = 2, setNames = 1, useNames = 0
   int [1:6] NA NA NA NA NA -15
   int [1:6] NA NA NA NA NA -15
  integer: NAs = TRUE, lag = 2, differences = 3, setNames = 1, useNames = 0
   int [1:4] NA NA NA NA
   int [1:4] NA NA NA NA
  integer: NAs = TRUE, lag = 2, differences = 4, setNames = 1, useNames = 0
   int [1:2] NA NA
   int [1:2] NA NA
  integer: NAs = TRUE, lag = 3, differences = 1, setNames = 1, useNames = 0
   int [1:7] NA NA NA NA NA NA 3
   int [1:7] NA NA NA NA NA NA 3
  integer: NAs = TRUE, lag = 3, differences = 2, setNames = 1, useNames = 0
   int [1:4] NA NA NA NA
   int [1:4] NA NA NA NA
  integer: NAs = TRUE, lag = 3, differences = 3, setNames = 1, useNames = 0
   int NA
   int NA
  integer: NAs = TRUE, lag = 3, differences = 4, setNames = 1, useNames = 0
   int(0) 
   int(0) 
  integer: NAs = TRUE, lag = 1, differences = 1, setNames = 0, useNames = 1
   Named int [1:9] NA NA NA NA NA NA NA NA NA
   - attr(*, "names")= chr [1:9] "B" "C" "D" "E" ...
   Named int [1:9] NA NA NA NA NA NA NA NA NA
   - attr(*, "names")= chr [1:9] "B" "C" "D" "E" ...
  integer: NAs = TRUE, lag = 1, differences = 2, setNames = 0, useNames = 1
   Named int [1:8] NA NA NA NA NA NA NA NA
   - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ...
   Named int [1:8] NA NA NA NA NA NA NA NA
   - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ...
  integer: NAs = TRUE, lag = 1, differences = 3, setNames = 0, useNames = 1
   Named int [1:7] NA NA NA NA NA NA NA
   - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ...
   Named int [1:7] NA NA NA NA NA NA NA
   - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ...
  integer: NAs = TRUE, lag = 1, differences = 4, setNames = 0, useNames = 1
   Named int [1:6] NA NA NA NA NA NA
   - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ...
   Named int [1:6] NA NA NA NA NA NA
   - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ...
  integer: NAs = TRUE, lag = 2, differences = 1, setNames = 0, useNames = 1
   Named int [1:8] NA NA NA NA NA NA NA NA
   - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ...
   Named int [1:8] NA NA NA NA NA NA NA NA
   - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ...
  integer: NAs = TRUE, lag = 2, differences = 2, setNames = 0, useNames = 1
   Named int [1:6] NA NA NA NA NA NA
   - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ...
   Named int [1:6] NA NA NA NA NA NA
   - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ...
  integer: NAs = TRUE, lag = 2, differences = 3, setNames = 0, useNames = 1
   Named int [1:4] NA NA NA NA
   - attr(*, "names")= chr [1:4] "G" "H" "I" "J"
   Named int [1:4] NA NA NA NA
   - attr(*, "names")= chr [1:4] "G" "H" "I" "J"
  integer: NAs = TRUE, lag = 2, differences = 4, setNames = 0, useNames = 1
   Named int [1:2] NA NA
   - attr(*, "names")= chr [1:2] "I" "J"
   Named int [1:2] NA NA
   - attr(*, "names")= chr [1:2] "I" "J"
  integer: NAs = TRUE, lag = 3, differences = 1, setNames = 0, useNames = 1
   Named int [1:7] NA NA NA NA NA NA 3
   - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ...
   Named int [1:7] NA NA NA NA NA NA 3
   - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ...
  integer: NAs = TRUE, lag = 3, differences = 2, setNames = 0, useNames = 1
   Named int [1:4] NA NA NA NA
   - attr(*, "names")= chr [1:4] "G" "H" "I" "J"
   Named int [1:4] NA NA NA NA
   - attr(*, "names")= chr [1:4] "G" "H" "I" "J"
  integer: NAs = TRUE, lag = 3, differences = 3, setNames = 0, useNames = 1
   Named int NA
   - attr(*, "names")= chr "J"
   Named int NA
   - attr(*, "names")= chr "J"
  integer: NAs = TRUE, lag = 3, differences = 4, setNames = 0, useNames = 1
   Named int(0) 
   - attr(*, "names")= chr(0) 
   Named int(0) 
   - attr(*, "names")= chr(0) 
  integer: NAs = TRUE, lag = 1, differences = 1, setNames = 0, useNames = 0
   int [1:9] NA NA NA NA NA NA NA NA NA
   int [1:9] NA NA NA NA NA NA NA NA NA
  integer: NAs = TRUE, lag = 1, differences = 2, setNames = 0, useNames = 0
   int [1:8] NA NA NA NA NA NA NA NA
   int [1:8] NA NA NA NA NA NA NA NA
  integer: NAs = TRUE, lag = 1, differences = 3, setNames = 0, useNames = 0
   int [1:7] NA NA NA NA NA NA NA
   int [1:7] NA NA NA NA NA NA NA
  integer: NAs = TRUE, lag = 1, differences = 4, setNames = 0, useNames = 0
   int [1:6] NA NA NA NA NA NA
   int [1:6] NA NA NA NA NA NA
  integer: NAs = TRUE, lag = 2, differences = 1, setNames = 0, useNames = 0
   int [1:8] NA NA NA NA NA NA NA NA
   int [1:8] NA NA NA NA NA NA NA NA
  integer: NAs = TRUE, lag = 2, differences = 2, setNames = 0, useNames = 0
   int [1:6] NA NA NA NA NA NA
   int [1:6] NA NA NA NA NA NA
  integer: NAs = TRUE, lag = 2, differences = 3, setNames = 0, useNames = 0
   int [1:4] NA NA NA NA
   int [1:4] NA NA NA NA
  integer: NAs = TRUE, lag = 2, differences = 4, setNames = 0, useNames = 0
   int [1:2] NA NA
   int [1:2] NA NA
  integer: NAs = TRUE, lag = 3, differences = 1, setNames = 0, useNames = 0
   int [1:7] NA NA NA NA NA NA 3
   int [1:7] NA NA NA NA NA NA 3
  integer: NAs = TRUE, lag = 3, differences = 2, setNames = 0, useNames = 0
   int [1:4] NA NA NA NA
   int [1:4] NA NA NA NA
  integer: NAs = TRUE, lag = 3, differences = 3, setNames = 0, useNames = 0
   int NA
   int NA
  integer: NAs = TRUE, lag = 3, differences = 4, setNames = 0, useNames = 0
   int(0) 
   int(0) 
   num [1:10] 2.586 -0.344 0.33 9.155 -3.254 ...
  double: NAs = FALSE, lag = 1, differences = 1, setNames = 1, useNames = 1
   Named num [1:9] -2.929 0.673 8.826 -12.409 -1.221 ...
   - attr(*, "names")= chr [1:9] "B" "C" "D" "E" ...
   Named num [1:9] -2.929 0.673 8.826 -12.409 -1.221 ...
   - attr(*, "names")= chr [1:9] "B" "C" "D" "E" ...
  double: NAs = FALSE, lag = 1, differences = 2, setNames = 1, useNames = 1
   Named num [1:8] 3.6 8.15 -21.23 11.19 -2.1 ...
   - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ...
   Named num [1:8] 3.6 8.15 -21.23 11.19 -2.1 ...
   - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ...
  double: NAs = FALSE, lag = 1, differences = 3, setNames = 1, useNames = 1
   Named num [1:7] 4.55 -29.39 32.42 -13.29 14.97 ...
   - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ...
   Named num [1:7] 4.55 -29.39 32.42 -13.29 14.97 ...
   - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ...
  double: NAs = FALSE, lag = 1, differences = 4, setNames = 1, useNames = 1
   Named num [1:6] -33.9 61.8 -45.7 28.3 -37 ...
   - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ...
   Named num [1:6] -33.9 61.8 -45.7 28.3 -37 ...
   - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ...
  double: NAs = FALSE, lag = 2, differences = 1, setNames = 1, useNames = 1
   Named num [1:8] -2.26 9.5 -3.58 -13.63 -4.54 ...
   - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ...
   Named num [1:8] -2.26 9.5 -3.58 -13.63 -4.54 ...
   - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ...
  double: NAs = FALSE, lag = 2, differences = 2, setNames = 1, useNames = 1
   Named num [1:6] -1.33 -23.13 -0.96 19.86 14.44 ...
   - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ...
   Named num [1:6] -1.33 -23.13 -0.96 19.86 14.44 ...
   - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ...
  double: NAs = FALSE, lag = 2, differences = 3, setNames = 1, useNames = 1
   Named num [1:4] 0.368 42.988 15.396 -29.313
   - attr(*, "names")= chr [1:4] "G" "H" "I" "J"
   Named num [1:4] 0.368 42.988 15.396 -29.313
   - attr(*, "names")= chr [1:4] "G" "H" "I" "J"
  double: NAs = FALSE, lag = 2, differences = 4, setNames = 1, useNames = 1
   Named num [1:2] 15 -72.3
   - attr(*, "names")= chr [1:2] "I" "J"
   Named num [1:2] 15 -72.3
   - attr(*, "names")= chr [1:2] "I" "J"
  double: NAs = FALSE, lag = 3, differences = 1, setNames = 1, useNames = 1
   Named num [1:7] 6.57 -2.91 -4.81 -16.95 5.01 ...
   - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ...
   Named num [1:7] 6.57 -2.91 -4.81 -16.95 5.01 ...
   - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ...
  double: NAs = FALSE, lag = 3, differences = 2, setNames = 1, useNames = 1
   Named num [1:4] -23.52 7.92 11.38 23.27
   - attr(*, "names")= chr [1:4] "G" "H" "I" "J"
   Named num [1:4] -23.52 7.92 11.38 23.27
   - attr(*, "names")= chr [1:4] "G" "H" "I" "J"
  double: NAs = FALSE, lag = 3, differences = 3, setNames = 1, useNames = 1
   Named num 46.8
   - attr(*, "names")= chr "J"
   Named num 46.8
   - attr(*, "names")= chr "J"
  double: NAs = FALSE, lag = 3, differences = 4, setNames = 1, useNames = 1
   Named num(0) 
   - attr(*, "names")= chr(0) 
   Named num(0) 
   - attr(*, "names")= chr(0) 
  double: NAs = FALSE, lag = 1, differences = 1, setNames = 1, useNames = 0
   num [1:9] -2.929 0.673 8.826 -12.409 -1.221 ...
   num [1:9] -2.929 0.673 8.826 -12.409 -1.221 ...
  double: NAs = FALSE, lag = 1, differences = 2, setNames = 1, useNames = 0
   num [1:8] 3.6 8.15 -21.23 11.19 -2.1 ...
   num [1:8] 3.6 8.15 -21.23 11.19 -2.1 ...
  double: NAs = FALSE, lag = 1, differences = 3, setNames = 1, useNames = 0
   num [1:7] 4.55 -29.39 32.42 -13.29 14.97 ...
   num [1:7] 4.55 -29.39 32.42 -13.29 14.97 ...
  double: NAs = FALSE, lag = 1, differences = 4, setNames = 1, useNames = 0
   num [1:6] -33.9 61.8 -45.7 28.3 -37 ...
   num [1:6] -33.9 61.8 -45.7 28.3 -37 ...
  double: NAs = FALSE, lag = 2, differences = 1, setNames = 1, useNames = 0
   num [1:8] -2.26 9.5 -3.58 -13.63 -4.54 ...
   num [1:8] -2.26 9.5 -3.58 -13.63 -4.54 ...
  double: NAs = FALSE, lag = 2, differences = 2, setNames = 1, useNames = 0
   num [1:6] -1.33 -23.13 -0.96 19.86 14.44 ...
   num [1:6] -1.33 -23.13 -0.96 19.86 14.44 ...
  double: NAs = FALSE, lag = 2, differences = 3, setNames = 1, useNames = 0
   num [1:4] 0.368 42.988 15.396 -29.313
   num [1:4] 0.368 42.988 15.396 -29.313
  double: NAs = FALSE, lag = 2, differences = 4, setNames = 1, useNames = 0
   num [1:2] 15 -72.3
   num [1:2] 15 -72.3
  double: NAs = FALSE, lag = 3, differences = 1, setNames = 1, useNames = 0
   num [1:7] 6.57 -2.91 -4.81 -16.95 5.01 ...
   num [1:7] 6.57 -2.91 -4.81 -16.95 5.01 ...
  double: NAs = FALSE, lag = 3, differences = 2, setNames = 1, useNames = 0
   num [1:4] -23.52 7.92 11.38 23.27
   num [1:4] -23.52 7.92 11.38 23.27
  double: NAs = FALSE, lag = 3, differences = 3, setNames = 1, useNames = 0
   num 46.8
   num 46.8
  double: NAs = FALSE, lag = 3, differences = 4, setNames = 1, useNames = 0
   num(0) 
   num(0) 
  double: NAs = FALSE, lag = 1, differences = 1, setNames = 0, useNames = 1
   Named num [1:9] -2.929 0.673 8.826 -12.409 -1.221 ...
   - attr(*, "names")= chr [1:9] "B" "C" "D" "E" ...
   Named num [1:9] -2.929 0.673 8.826 -12.409 -1.221 ...
   - attr(*, "names")= chr [1:9] "B" "C" "D" "E" ...
  double: NAs = FALSE, lag = 1, differences = 2, setNames = 0, useNames = 1
   Named num [1:8] 3.6 8.15 -21.23 11.19 -2.1 ...
   - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ...
   Named num [1:8] 3.6 8.15 -21.23 11.19 -2.1 ...
   - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ...
  double: NAs = FALSE, lag = 1, differences = 3, setNames = 0, useNames = 1
   Named num [1:7] 4.55 -29.39 32.42 -13.29 14.97 ...
   - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ...
   Named num [1:7] 4.55 -29.39 32.42 -13.29 14.97 ...
   - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ...
  double: NAs = FALSE, lag = 1, differences = 4, setNames = 0, useNames = 1
   Named num [1:6] -33.9 61.8 -45.7 28.3 -37 ...
   - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ...
   Named num [1:6] -33.9 61.8 -45.7 28.3 -37 ...
   - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ...
  double: NAs = FALSE, lag = 2, differences = 1, setNames = 0, useNames = 1
   Named num [1:8] -2.26 9.5 -3.58 -13.63 -4.54 ...
   - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ...
   Named num [1:8] -2.26 9.5 -3.58 -13.63 -4.54 ...
   - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ...
  double: NAs = FALSE, lag = 2, differences = 2, setNames = 0, useNames = 1
   Named num [1:6] -1.33 -23.13 -0.96 19.86 14.44 ...
   - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ...
   Named num [1:6] -1.33 -23.13 -0.96 19.86 14.44 ...
   - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ...
  double: NAs = FALSE, lag = 2, differences = 3, setNames = 0, useNames = 1
   Named num [1:4] 0.368 42.988 15.396 -29.313
   - attr(*, "names")= chr [1:4] "G" "H" "I" "J"
   Named num [1:4] 0.368 42.988 15.396 -29.313
   - attr(*, "names")= chr [1:4] "G" "H" "I" "J"
  double: NAs = FALSE, lag = 2, differences = 4, setNames = 0, useNames = 1
   Named num [1:2] 15 -72.3
   - attr(*, "names")= chr [1:2] "I" "J"
   Named num [1:2] 15 -72.3
   - attr(*, "names")= chr [1:2] "I" "J"
  double: NAs = FALSE, lag = 3, differences = 1, setNames = 0, useNames = 1
   Named num [1:7] 6.57 -2.91 -4.81 -16.95 5.01 ...
   - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ...
   Named num [1:7] 6.57 -2.91 -4.81 -16.95 5.01 ...
   - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ...
  double: NAs = FALSE, lag = 3, differences = 2, setNames = 0, useNames = 1
   Named num [1:4] -23.52 7.92 11.38 23.27
   - attr(*, "names")= chr [1:4] "G" "H" "I" "J"
   Named num [1:4] -23.52 7.92 11.38 23.27
   - attr(*, "names")= chr [1:4] "G" "H" "I" "J"
  double: NAs = FALSE, lag = 3, differences = 3, setNames = 0, useNames = 1
   Named num 46.8
   - attr(*, "names")= chr "J"
   Named num 46.8
   - attr(*, "names")= chr "J"
  double: NAs = FALSE, lag = 3, differences = 4, setNames = 0, useNames = 1
   Named num(0) 
   - attr(*, "names")= chr(0) 
   Named num(0) 
   - attr(*, "names")= chr(0) 
  double: NAs = FALSE, lag = 1, differences = 1, setNames = 0, useNames = 0
   num [1:9] -2.929 0.673 8.826 -12.409 -1.221 ...
   num [1:9] -2.929 0.673 8.826 -12.409 -1.221 ...
  double: NAs = FALSE, lag = 1, differences = 2, setNames = 0, useNames = 0
   num [1:8] 3.6 8.15 -21.23 11.19 -2.1 ...
   num [1:8] 3.6 8.15 -21.23 11.19 -2.1 ...
  double: NAs = FALSE, lag = 1, differences = 3, setNames = 0, useNames = 0
   num [1:7] 4.55 -29.39 32.42 -13.29 14.97 ...
   num [1:7] 4.55 -29.39 32.42 -13.29 14.97 ...
  double: NAs = FALSE, lag = 1, differences = 4, setNames = 0, useNames = 0
   num [1:6] -33.9 61.8 -45.7 28.3 -37 ...
   num [1:6] -33.9 61.8 -45.7 28.3 -37 ...
  double: NAs = FALSE, lag = 2, differences = 1, setNames = 0, useNames = 0
   num [1:8] -2.26 9.5 -3.58 -13.63 -4.54 ...
   num [1:8] -2.26 9.5 -3.58 -13.63 -4.54 ...
  double: NAs = FALSE, lag = 2, differences = 2, setNames = 0, useNames = 0
   num [1:6] -1.33 -23.13 -0.96 19.86 14.44 ...
   num [1:6] -1.33 -23.13 -0.96 19.86 14.44 ...
  double: NAs = FALSE, lag = 2, differences = 3, setNames = 0, useNames = 0
   num [1:4] 0.368 42.988 15.396 -29.313
   num [1:4] 0.368 42.988 15.396 -29.313
  double: NAs = FALSE, lag = 2, differences = 4, setNames = 0, useNames = 0
   num [1:2] 15 -72.3
   num [1:2] 15 -72.3
  double: NAs = FALSE, lag = 3, differences = 1, setNames = 0, useNames = 0
   num [1:7] 6.57 -2.91 -4.81 -16.95 5.01 ...
   num [1:7] 6.57 -2.91 -4.81 -16.95 5.01 ...
  double: NAs = FALSE, lag = 3, differences = 2, setNames = 0, useNames = 0
   num [1:4] -23.52 7.92 11.38 23.27
   num [1:4] -23.52 7.92 11.38 23.27
  double: NAs = FALSE, lag = 3, differences = 3, setNames = 0, useNames = 0
   num 46.8
   num 46.8
  double: NAs = FALSE, lag = 3, differences = 4, setNames = 0, useNames = 0
   num(0) 
   num(0) 
  double: NAs = TRUE, lag = 1, differences = 1, setNames = 1, useNames = 1
   Named num [1:9] -2.929 0.673 8.826 NA NA ...
   - attr(*, "names")= chr [1:9] "B" "C" "D" "E" ...
   Named num [1:9] -2.929 0.673 8.826 NA NA ...
   - attr(*, "names")= chr [1:9] "B" "C" "D" "E" ...
  double: NAs = TRUE, lag = 1, differences = 2, setNames = 1, useNames = 1
   Named num [1:8] 3.6 8.15 NA NA NA ...
   - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ...
   Named num [1:8] 3.6 8.15 NA NA NA ...
   - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ...
  double: NAs = TRUE, lag = 1, differences = 3, setNames = 1, useNames = 1
   Named num [1:7] 4.55 NA NA NA NA ...
   - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ...
   Named num [1:7] 4.55 NA NA NA NA ...
   - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ...
  double: NAs = TRUE, lag = 1, differences = 4, setNames = 1, useNames = 1
   Named num [1:6] NA NA NA NA NA NA
   - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ...
   Named num [1:6] NA NA NA NA NA NA
   - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ...
  double: NAs = TRUE, lag = 2, differences = 1, setNames = 1, useNames = 1
   Named num [1:8] -2.26 9.5 NA NA NA ...
   - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ...
   Named num [1:8] -2.26 9.5 NA NA NA ...
   - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ...
  double: NAs = TRUE, lag = 2, differences = 2, setNames = 1, useNames = 1
   Named num [1:6] NA NA NA NA NA NA
   - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ...
   Named num [1:6] NA NA NA NA NA NA
   - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ...
  double: NAs = TRUE, lag = 2, differences = 3, setNames = 1, useNames = 1
   Named num [1:4] NA NA NA NA
   - attr(*, "names")= chr [1:4] "G" "H" "I" "J"
   Named num [1:4] NA NA NA NA
   - attr(*, "names")= chr [1:4] "G" "H" "I" "J"
  double: NAs = TRUE, lag = 2, differences = 4, setNames = 1, useNames = 1
   Named num [1:2] NA NA
   - attr(*, "names")= chr [1:2] "I" "J"
   Named num [1:2] NA NA
   - attr(*, "names")= chr [1:2] "I" "J"
  double: NAs = TRUE, lag = 3, differences = 1, setNames = 1, useNames = 1
   Named num [1:7] 6.57 NA NA -16.95 NA ...
   - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ...
   Named num [1:7] 6.57 NA NA -16.95 NA ...
   - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ...
  double: NAs = TRUE, lag = 3, differences = 2, setNames = 1, useNames = 1
   Named num [1:4] -23.5 NA NA 23.3
   - attr(*, "names")= chr [1:4] "G" "H" "I" "J"
   Named num [1:4] -23.5 NA NA 23.3
   - attr(*, "names")= chr [1:4] "G" "H" "I" "J"
  double: NAs = TRUE, lag = 3, differences = 3, setNames = 1, useNames = 1
   Named num 46.8
   - attr(*, "names")= chr "J"
   Named num 46.8
   - attr(*, "names")= chr "J"
  double: NAs = TRUE, lag = 3, differences = 4, setNames = 1, useNames = 1
   Named num(0) 
   - attr(*, "names")= chr(0) 
   Named num(0) 
   - attr(*, "names")= chr(0) 
  double: NAs = TRUE, lag = 1, differences = 1, setNames = 1, useNames = 0
   num [1:9] NA 0.673 8.826 NA NA ...
   num [1:9] NA 0.673 8.826 NA NA ...
  double: NAs = TRUE, lag = 1, differences = 2, setNames = 1, useNames = 0
   num [1:8] NA 8.15 NA NA NA ...
   num [1:8] NA 8.15 NA NA NA ...
  double: NAs = TRUE, lag = 1, differences = 3, setNames = 1, useNames = 0
   num [1:7] NA NA NA NA NA NA NA
   num [1:7] NA NA NA NA NA NA NA
  double: NAs = TRUE, lag = 1, differences = 4, setNames = 1, useNames = 0
   num [1:6] NA NA NA NA NA NA
   num [1:6] NA NA NA NA NA NA
  double: NAs = TRUE, lag = 2, differences = 1, setNames = 1, useNames = 0
   num [1:8] NA 9.5 NA NA NA ...
   num [1:8] NA 9.5 NA NA NA ...
  double: NAs = TRUE, lag = 2, differences = 2, setNames = 1, useNames = 0
   num [1:6] NA NA NA NA NA NA
   num [1:6] NA NA NA NA NA NA
  double: NAs = TRUE, lag = 2, differences = 3, setNames = 1, useNames = 0
   num [1:4] NA NA NA NA
   num [1:4] NA NA NA NA
  double: NAs = TRUE, lag = 2, differences = 4, setNames = 1, useNames = 0
   num [1:2] NA NA
   num [1:2] NA NA
  double: NAs = TRUE, lag = 3, differences = 1, setNames = 1, useNames = 0
   num [1:7] NA NA NA NA NA NA NA
   num [1:7] NA NA NA NA NA NA NA
  double: NAs = TRUE, lag = 3, differences = 2, setNames = 1, useNames = 0
   num [1:4] NA NA NA NA
   num [1:4] NA NA NA NA
  double: NAs = TRUE, lag = 3, differences = 3, setNames = 1, useNames = 0
   num NA
   num NA
  double: NAs = TRUE, lag = 3, differences = 4, setNames = 1, useNames = 0
   num(0) 
   num(0) 
  double: NAs = TRUE, lag = 1, differences = 1, setNames = 0, useNames = 1
   Named num [1:9] NA 0.673 8.826 NA NA ...
   - attr(*, "names")= chr [1:9] "B" "C" "D" "E" ...
   Named num [1:9] NA 0.673 8.826 NA NA ...
   - attr(*, "names")= chr [1:9] "B" "C" "D" "E" ...
  double: NAs = TRUE, lag = 1, differences = 2, setNames = 0, useNames = 1
   Named num [1:8] NA 8.15 NA NA NA ...
   - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ...
   Named num [1:8] NA 8.15 NA NA NA ...
   - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ...
  double: NAs = TRUE, lag = 1, differences = 3, setNames = 0, useNames = 1
   Named num [1:7] NA NA NA NA NA NA NA
   - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ...
   Named num [1:7] NA NA NA NA NA NA NA
   - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ...
  double: NAs = TRUE, lag = 1, differences = 4, setNames = 0, useNames = 1
   Named num [1:6] NA NA NA NA NA NA
   - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ...
   Named num [1:6] NA NA NA NA NA NA
   - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ...
  double: NAs = TRUE, lag = 2, differences = 1, setNames = 0, useNames = 1
   Named num [1:8] NA 9.5 NA NA NA ...
   - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ...
   Named num [1:8] NA 9.5 NA NA NA ...
   - attr(*, "names")= chr [1:8] "C" "D" "E" "F" ...
  double: NAs = TRUE, lag = 2, differences = 2, setNames = 0, useNames = 1
   Named num [1:6] NA NA NA NA NA NA
   - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ...
   Named num [1:6] NA NA NA NA NA NA
   - attr(*, "names")= chr [1:6] "E" "F" "G" "H" ...
  double: NAs = TRUE, lag = 2, differences = 3, setNames = 0, useNames = 1
   Named num [1:4] NA NA NA NA
   - attr(*, "names")= chr [1:4] "G" "H" "I" "J"
   Named num [1:4] NA NA NA NA
   - attr(*, "names")= chr [1:4] "G" "H" "I" "J"
  double: NAs = TRUE, lag = 2, differences = 4, setNames = 0, useNames = 1
   Named num [1:2] NA NA
   - attr(*, "names")= chr [1:2] "I" "J"
   Named num [1:2] NA NA
   - attr(*, "names")= chr [1:2] "I" "J"
  double: NAs = TRUE, lag = 3, differences = 1, setNames = 0, useNames = 1
   Named num [1:7] NA NA NA NA NA NA NA
   - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ...
   Named num [1:7] NA NA NA NA NA NA NA
   - attr(*, "names")= chr [1:7] "D" "E" "F" "G" ...
  double: NAs = TRUE, lag = 3, differences = 2, setNames = 0, useNames = 1
   Named num [1:4] NA NA NA NA
   - attr(*, "names")= chr [1:4] "G" "H" "I" "J"
   Named num [1:4] NA NA NA NA
   - attr(*, "names")= chr [1:4] "G" "H" "I" "J"
  double: NAs = TRUE, lag = 3, differences = 3, setNames = 0, useNames = 1
   Named num NA
   - attr(*, "names")= chr "J"
   Named num NA
   - attr(*, "names")= chr "J"
  double: NAs = TRUE, lag = 3, differences = 4, setNames = 0, useNames = 1
   Named num(0) 
   - attr(*, "names")= chr(0) 
   Named num(0) 
   - attr(*, "names")= chr(0) 
  double: NAs = TRUE, lag = 1, differences = 1, setNames = 0, useNames = 0
   num [1:9] NA 0.673 8.826 NA NA ...
   num [1:9] NA 0.673 8.826 NA NA ...
  double: NAs = TRUE, lag = 1, differences = 2, setNames = 0, useNames = 0
   num [1:8] NA 8.15 NA NA NA ...
   num [1:8] NA 8.15 NA NA NA ...
  double: NAs = TRUE, lag = 1, differences = 3, setNames = 0, useNames = 0
   num [1:7] NA NA NA NA NA NA NA
   num [1:7] NA NA NA NA NA NA NA
  double: NAs = TRUE, lag = 1, differences = 4, setNames = 0, useNames = 0
   num [1:6] NA NA NA NA NA NA
   num [1:6] NA NA NA NA NA NA
  double: NAs = TRUE, lag = 2, differences = 1, setNames = 0, useNames = 0
   num [1:8] NA 9.5 NA NA NA ...
   num [1:8] NA 9.5 NA NA NA ...
  double: NAs = TRUE, lag = 2, differences = 2, setNames = 0, useNames = 0
   num [1:6] NA NA NA NA NA NA
   num [1:6] NA NA NA NA NA NA
  double: NAs = TRUE, lag = 2, differences = 3, setNames = 0, useNames = 0
   num [1:4] NA NA NA NA
   num [1:4] NA NA NA NA
  double: NAs = TRUE, lag = 2, differences = 4, setNames = 0, useNames = 0
   num [1:2] NA NA
   num [1:2] NA NA
  double: NAs = TRUE, lag = 3, differences = 1, setNames = 0, useNames = 0
   num [1:7] NA NA NA NA NA NA NA
   num [1:7] NA NA NA NA NA NA NA
  double: NAs = TRUE, lag = 3, differences = 2, setNames = 0, useNames = 0
   num [1:4] NA NA NA NA
   num [1:4] NA NA NA NA
  double: NAs = TRUE, lag = 3, differences = 3, setNames = 0, useNames = 0
   num NA
   num NA
  double: NAs = TRUE, lag = 3, differences = 4, setNames = 0, useNames = 0
   num(0) 
   num(0) 
  > 
  > proc.time()
     user  system elapsed 
     0.46    0.06    0.53 
Running the tests in 'tests/logSumExp_subset.R' failed.
Complete output:
  > library("matrixStats")
  > 
  > logSumExp_R <- function(lx, na.rm = FALSE) {
  +   log(sum(exp(lx), na.rm = na.rm))
  + }
  > 
  > 
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > # Subsetted tests
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > source("utils/validateIndicesFramework.R")
  > x <- runif(6, min = -6, max = 6)
  > for (idxs in index_cases) {
  +   validateIndicesTestVector(x, idxs,
  +                             ftest = logSumExp, fsure = logSumExp_R,
  +                             na.rm = FALSE)
  +   validateIndicesTestVector(x, idxs,
  +                             ftest = logSumExp, fsure = logSumExp_R,
  +                             na.rm = TRUE)
  + }
  > 
  > proc.time()
     user  system elapsed 
     0.29    0.06    0.28 
Running the tests in 'tests/mean2.R' failed.
Complete output:
  > library("matrixStats")
  > 
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > # Consistency checks
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > set.seed(1)
  > 
  > mean2_R <- function(x, na.rm = FALSE, idxs = NULL) {
  +   if (is.null(idxs)) {
  +     mean(x, na.rm = na.rm)
  +   } else {
  +     mean(x[idxs], na.rm = na.rm)
  +   }
  + } # mean2_R()
  > 
  > 
  > cat("Consistency checks:\n")
  Consistency checks:
  > for (kk in 1:20) {
  +   cat("Random test #", kk, "\n", sep = "")
  + 
  +   # Simulate data in a matrix of any shape
  +   n <- sample(100L, size = 1L)
  +   x <- rnorm(n, sd = 100)
  + 
  +   # Add NAs?
  +   if ((kk %% 4) %in% c(3, 0)) {
  +     cat("Adding NAs\n")
  +     nna <- sample(n, size = 1L)
  +     na_values <- c(NA_real_, NaN)
  +     t <- sample(na_values, size = nna, replace = TRUE)
  +     x[sample(length(x), size = nna)] <- t
  +   }
  + 
  +   # Integer or double?
  +   if ((kk %% 4) %in% c(2, 0)) {
  +     cat("Coercing to integers\n")
  +     storage.mode(x) <- "integer"
  +   }
  + 
  +   na.rm <- sample(c(TRUE, FALSE), size = 1L)
  + 
  +   # Sum over all
  +   y0 <- mean2_R(x, na.rm = na.rm)
  +   y1 <- mean2(x, na.rm = na.rm)
  +   stopifnot(all.equal(y1, y0))
  + 
  +   # Sum over subset
  +   nidxs <- sample(n, size = 1L)
  +   idxs <- sample(n, size = nidxs)
  +   y0 <- mean2_R(x, na.rm = na.rm, idxs = idxs)
  +   y1 <- mean2(x, na.rm = na.rm, idxs = idxs)
  +   stopifnot(all.equal(y1, y0))
  + 
  +   if (storage.mode(x) == "integer") {
  +     storage.mode(x) <- "logical"
  +     
  +     y0 <- mean2_R(x, na.rm = na.rm)
  +     y1 <- mean2(x, na.rm = na.rm)
  +     stopifnot(all.equal(y1, y0))
  +     
  +     y0 <- mean2_R(x, na.rm = na.rm, idxs = idxs)
  +     y1 <- mean2(x, na.rm = na.rm, idxs = idxs)
  +     stopifnot(all.equal(y1, y0))
  +   }
  + } # for (kk ...)
  Random test #1
  Random test #2
  Coercing to integers
  Random test #3
  Adding NAs
  Random test #4
  Adding NAs
  Coercing to integers
  Random test #5
  Random test #6
  Coercing to integers
  Random test #7
  Adding NAs
  Random test #8
  Adding NAs
  Coercing to integers
  Random test #9
  Random test #10
  Coercing to integers
  Random test #11
  Adding NAs
  Random test #12
  Adding NAs
  Coercing to integers
  Random test #13
  Random test #14
  Coercing to integers
  Random test #15
  Adding NAs
  Random test #16
  Adding NAs
  Coercing to integers
  Random test #17
  Random test #18
  Coercing to integers
  Random test #19
  Adding NAs
  Random test #20
  Adding NAs
  Coercing to integers
  > 
  > 
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > # Special cases
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > for (na.rm in c(FALSE, TRUE)) {
  +   # Averaging over zero elements (integers)
  +   x <- integer(0)
  +   s1 <- mean(x, na.rm = na.rm)
  +   s2 <- mean2(x, na.rm = na.rm)
  +   stopifnot(identical(s1, s2))
  + 
  +   x <- 1:5
  +   idxs <- integer(0)
  +   s1 <- mean(x[idxs], na.rm = na.rm)
  +   s2 <- mean2(x, idxs = idxs, na.rm = na.rm)
  +   stopifnot(identical(s1, s2))
  + 
  +   # Averaging over NA_integer_:s
  +   x <- rep(NA_integer_, times = 5L)
  +   s1 <- mean(x, na.rm = na.rm)
  +   s2 <- mean2(x, na.rm = na.rm)
  +   stopifnot(identical(s1, s2))
  + 
  +   x <- rep(NA_integer_, times = 5L)
  +   idxs <- 1:3
  +   s1 <- mean(x[idxs], na.rm = na.rm)
  +   s2 <- mean2(x, idxs = idxs, na.rm = na.rm)
  +   stopifnot(identical(s1, s2))
  + 
  + 
  +   # Averaging over zero elements (doubles)
  +   x <- double(0)
  +   s1 <- mean(x)
  +   s2 <- mean2(x)
  +   stopifnot(identical(s1, s2))
  + 
  +   x <- as.double(1:10)
  +   idxs <- integer(0)
  +   s1 <- mean(x[idxs])
  +   s2 <- mean2(x, idxs = idxs)
  +   stopifnot(identical(s1, s2))
  + 
  +   # Averaging over NA_real_:s
  +   x <- rep(NA_real_, times = 5L)
  +   s1 <- mean(x, na.rm = na.rm)
  +   s2 <- mean2(x, na.rm = na.rm)
  +   stopifnot(identical(s1, s2))
  + 
  +   x <- rep(NA_real_, times = 5L)
  +   idxs <- 1:3
  +   s1 <- mean(x[idxs], na.rm = na.rm)
  +   s2 <- mean2(x, idxs = idxs, na.rm = na.rm)
  +   stopifnot(identical(s1, s2))
  + 
  +   # Averaging over -Inf:s
  +   x <- rep(-Inf, times = 3L)
  +   s1 <- mean(x, na.rm = na.rm)
  +   s2 <- mean2(x, na.rm = na.rm)
  +   stopifnot(identical(s1, s2))
  + 
  +   # Averaging over +Inf:s
  +   x <- rep(+Inf, times = 3L)
  +   s1 <- mean(x, na.rm = na.rm)
  +   s2 <- mean2(x, na.rm = na.rm)
  +   stopifnot(identical(s1, s2))
  + 
  +   # Averaging over mix of -Inf:s and +Inf:s
  +   x <- rep(c(-Inf, +Inf), times = 3L)
  +   s1 <- mean(x, na.rm = na.rm)
  +   s2 <- mean2(x, na.rm = na.rm)
  +   stopifnot(identical(s1, s2))
  + 
  +   # Averaging over mix of -Inf:s and +Inf:s and numerics
  +   x <- rep(c(-Inf, +Inf, 3.14), times = 2L)
  +   s1 <- mean(x, na.rm = na.rm)
  +   s2 <- mean2(x, na.rm = na.rm)
  +   stopifnot(identical(s1, s2))
  + 
  +   # Averaging over mix of NaN, NA, +Inf, and numerics
  +   x <- c(NaN, NA, +Inf, 3.14)
  +   s1 <- mean(x, na.rm = na.rm)
  +   s2 <- mean2(x, na.rm = na.rm)
  +   if (na.rm) {
  +     stopifnot(identical(s2, s1))
  +   } else {
  +     stopifnot(is.na(s1), is.na(s2))
  +     ## NOTE, due to compiler optimization, it is not guaranteed that NA is
  +     ## returned here (as one would expect). NaN might very well be returned,
  +     ## when both NA and NaN are involved.  This is an accepted feature in R,
  +     ## which is documented in help("is.nan").  See also
  +     ## https://stat.ethz.ch/pipermail/r-devel/2017-April/074009.html.
  +     ## Thus, we cannot guarantee that s1 is identical to s0.
  +   }
  + 
  +   # Averaging over mix of NaN, NA_real_, +Inf, and numerics
  +   x <- c(NA_real_, NaN, +Inf, 3.14)
  +   s1 <- mean(x, na.rm = na.rm)
  +   s2 <- mean2(x, na.rm = na.rm)
  +   if (na.rm) {
  +     stopifnot(identical(s2, s1))
  +   } else {
  +     stopifnot(is.na(s1), is.na(s2))
  +     ## NOTE, due to compiler optimization, it is not guaranteed that NA is
  +     ## returned here (as one would expect). NaN might very well be returned,
  +     ## when both NA and NaN are involved.  This is an accepted feature in R,
  +     ## which is documented in help("is.nan").  See also
  +     ## https://stat.ethz.ch/pipermail/r-devel/2017-April/074009.html.
  +     ## Thus, we cannot guarantee that s1 is identical to s0.
  +   }
  + }
  > 
  > 
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > # Argument 'idxs'
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > x <- 1:5
  > idxs_list <- list(
  +   integer = 1:3,
  +   double  = as.double(1:3),
  +   logical = (x <= 3)
  + )
  > 
  > for (idxs in idxs_list) {
  +   cat("idxs:\n")
  +   str(idxs)
  +   s1 <- mean(x[idxs], na.rm = TRUE)
  +   s2 <- mean2(x, idxs = idxs, na.rm = TRUE)
  +   stopifnot(identical(s1, s2))
  + }
  idxs:
   int [1:3] 1 2 3
  idxs:
   num [1:3] 1 2 3
  idxs:
   logi [1:5] TRUE TRUE TRUE FALSE FALSE
  > 
  > proc.time()
     user  system elapsed 
     0.28    0.06    0.32 
Running the tests in 'tests/mean2_subset.R' failed.
Complete output:
  > library("matrixStats")
  > 
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > # Subsetted tests
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > source("utils/validateIndicesFramework.R")
  > x <- runif(6, min = -6, max = 6)
  > storage.mode(x) <- "integer"
  > for (idxs in index_cases) {
  +   validateIndicesTestVector(x, idxs,
  +                             ftest = mean2, fsure = mean,
  +                             na.rm = FALSE)
  +   validateIndicesTestVector(x, idxs,
  +                             ftest = mean2, fsure = mean,
  +                             na.rm = TRUE)
  + }
  > 
  > proc.time()
     user  system elapsed 
     0.26    0.07    0.28 
Running the tests in 'tests/product.R' failed.
Complete output:
  > library("matrixStats")
  > 
  > for (mode in c("integer", "double")) {
  +   cat("mode: ", mode, "\n", sep = "")
  + 
  +   # Empty vector
  +   x <- 0
  +   storage.mode(x) <- mode
  +   y <- prod(x, na.rm = TRUE)
  +   print(y)
  +   z <- product(x, na.rm = TRUE)
  +   print(z)
  +   stopifnot(all.equal(z, y))
  + 
  +   # Test negative values
  +   x <- c(1, -4, 2)
  +   storage.mode(x) <- mode
  +   y <- prod(x, na.rm = TRUE)
  +   print(y)
  +   z <- product(x, na.rm = TRUE)
  +   print(z)
  +   stopifnot(all.equal(z, y))
  + 
  +   # Test missing values
  +   x <- c(1, NA, NaN, 2)
  +   storage.mode(x) <- mode
  +   y <- prod(x, na.rm = TRUE)
  +   print(y)
  +   z <- product(x, na.rm = TRUE)
  +   print(z)
  +   stopifnot(all.equal(z, y))
  + 
  +   x <- c(1, NA, NaN, 2)
  +   storage.mode(x) <- mode
  +   y <- prod(x, na.rm = FALSE)
  +   print(y)
  +   z <- product(x, na.rm = FALSE)
  +   print(z)
  +   stopifnot(all(is.na(z), is.na(y)))
  + 
  +   x <- c(1, NaN, 2)
  +   storage.mode(x) <- mode
  +   y <- prod(x, na.rm = FALSE)
  +   print(y)
  +   stopifnot(is.na(y))
  +   z <- product(x, na.rm = FALSE)
  +   print(z)
  +   stopifnot(is.na(z))
  + 
  + } # for (mode ...)
  mode: integer
  [1] 0
  [1] 0
  [1] -8
  [1] -8
  [1] 2
  [1] 2
  [1] NA
  [1] NA
  [1] NA
  [1] NA
  mode: double
  [1] 0
  [1] 0
  [1] -8
  [1] -8
  [1] 2
  [1] 2
  [1] NA
  [1] NA
  [1] NaN
  [1] NA
  > 
  > 
  > # NAs following 0s
  > x <- c(0L, NA_integer_)
  > y <- prod(x, na.rm = FALSE)
  > print(y)
  [1] NA
  > z <- product(x, na.rm = FALSE)
  > print(z)
  [1] NA
  > stopifnot(identical(z, y))
  > 
  > proc.time()
     user  system elapsed 
     0.26    0.10    0.31 
Running the tests in 'tests/rowAllAnys.R' failed.
Complete output:
  > library("matrixStats")
  > 
  > rowAlls_R <- function(x, value = TRUE, na.rm = FALSE, ..., useNames = NA) {
  +   if (is.na(value)) {
  +     res <- apply(is.na(x), MARGIN = 1L, FUN = all, na.rm = na.rm)
  +   } else {
  +     y <- x == value
  +     
  +     # Preserve dimnames attribute
  +     dim <- dim(x) # for 0xN and Mx0 cases; needed in R (< 3.4.0)
  +     if (!isTRUE(all.equal(dim(y), dim))) {
  +       dim(y) <- dim
  +       dimnames(y) <- dimnames(x)
  +     }
  +     
  +     res <- apply(y, MARGIN = 1L, FUN = all, na.rm = na.rm)
  +   }
  +   if (is.na(useNames) || !useNames) names(res) <- NULL
  +   res
  + }
  > 
  > rowAnys_R <- function(x, value = TRUE, na.rm = FALSE, ..., useNames = NA) {
  +   if (is.na(value)) {
  +     res <- apply(is.na(x), MARGIN = 1L, FUN = any, na.rm = na.rm)
  +   } else {
  +     y <- x == value
  +     
  +     # Preserve dimnames attribute
  +     dim <- dim(x) # for 0xN and Mx0 cases; needed in R (< 3.4.0)
  +     if (!isTRUE(all.equal(dim(y), dim))) {
  +       dim(y) <- dim
  +       dimnames(y) <- dimnames(x)
  +     }
  +     
  +     res <- apply(y, MARGIN = 1L, FUN = any, na.rm = na.rm)
  +   }
  +   if (is.na(useNames) || !useNames) names(res) <- NULL
  +   res
  + }
  > 
  > rowAnyMissings_R <- function(x, ..., useNames = NA) {
  +   res <- apply(x, MARGIN = 1L, FUN = anyMissing)
  +   if (is.na(useNames) || !useNames) names(res) <- NULL
  +   res
  + }
  > 
  > 
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > # Data type: logical
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > x <- matrix(FALSE, nrow = 10L, ncol = 4L)
  > x[7:8, 2:3] <- TRUE
  > x[1:3, ] <- TRUE
  > x[, 1] <- TRUE
  > x[4, ] <- FALSE
  > x[, 4] <- FALSE
  > x[2, ] <- FALSE
  > x[3, ] <- TRUE
  > 
  > # To check names attribute
  > dimnames <- list(letters[1:10], LETTERS[1:4])
  > 
  > for (kk in 1:3) {
  +   if (kk == 2) {
  +     x[2, 2] <- NA
  +   } else if (kk == 3) {
  +     x[, 2] <- NA
  +     x[2, ] <- NA
  +   }
  + 
  +   # Test with and without dimnames on x
  +   for (setDimnames in c(TRUE, FALSE)) {
  +     dimnames(x) <- if (setDimnames) dimnames else NULL
  + 
  +     for (na.rm in c(FALSE, TRUE)) {
  +       # Check names attribute
  +       for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) {
  +         m0 <- rowAlls_R(x, na.rm = na.rm, useNames = useNames)
  +         m1 <- rowAlls(x, na.rm = na.rm, useNames = useNames)
  +         m2 <- colAlls(t(x), na.rm = na.rm, useNames = useNames)
  +         str(list("all()", m0 = m0, m1 = m1, m2 = m2))
  +         stopifnot(identical(m1, m0))
  +         stopifnot(identical(m2, m0))        
  + 
  +         m0 <- rowAnys_R(x, na.rm = na.rm, useNames = useNames)
  +         m1 <- rowAnys(x, na.rm = na.rm, useNames = useNames)
  +         m2 <- colAnys(t(x), na.rm = na.rm, useNames = useNames)
  +         str(list("any()", m0 = m0, m1 = m1, m2 = m2))
  +         stopifnot(identical(m1, m0))
  +         stopifnot(identical(m2, m0))
  +         
  +         m0 <- rowAnyMissings_R(x, useNames = useNames)
  +         m1 <- rowAnyMissings(x, useNames = useNames)
  +         m2 <- colAnyMissings(t(x), useNames = useNames)
  +         str(list("anyMissing()", m0 = m0, m1 = m1, m2 = m2))
  +         stopifnot(identical(m1, m0))
  +         stopifnot(identical(m2, m0))
  +       }
  +     }
  +   }
  + } # for (kk ...)
  List of 4
   $   : chr "all()"
   $ m0: Named logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ...
    ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ...
   $ m1: Named logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ...
    ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ...
   $ m2: Named logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ...
    ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ...
  List of 4
   $   : chr "any()"
   $ m0: Named logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ...
    ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ...
   $ m1: Named logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ...
    ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ...
   $ m2: Named logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ...
    ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ...
  List of 4
   $   : chr "anyMissing()"
   $ m0: Named logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ...
    ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ...
   $ m1: Named logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ...
    ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ...
   $ m2: Named logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ...
    ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ...
  List of 4
   $   : chr "all()"
   $ m0: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ...
   $ m1: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ...
   $ m2: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ...
  List of 4
   $   : chr "any()"
   $ m0: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ...
   $ m1: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ...
   $ m2: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ...
  List of 4
   $   : chr "anyMissing()"
   $ m0: logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ...
   $ m1: logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ...
   $ m2: logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ...
  List of 4
   $   : chr "all()"
   $ m0: Named logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ...
    ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ...
   $ m1: Named logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ...
    ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ...
   $ m2: Named logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ...
    ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ...
  List of 4
   $   : chr "any()"
   $ m0: Named logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ...
    ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ...
   $ m1: Named logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ...
    ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ...
   $ m2: Named logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ...
    ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ...
  List of 4
   $   : chr "anyMissing()"
   $ m0: Named logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ...
    ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ...
   $ m1: Named logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ...
    ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ...
   $ m2: Named logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ...
    ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ...
  List of 4
   $   : chr "all()"
   $ m0: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ...
   $ m1: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ...
   $ m2: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ...
  List of 4
   $   : chr "any()"
   $ m0: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ...
   $ m1: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ...
   $ m2: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ...
  List of 4
   $   : chr "anyMissing()"
   $ m0: logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ...
   $ m1: logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ...
   $ m2: logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ...
  List of 4
   $   : chr "all()"
   $ m0: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ...
   $ m1: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ...
   $ m2: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ...
  List of 4
   $   : chr "any()"
   $ m0: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ...
   $ m1: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ...
   $ m2: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ...
  List of 4
   $   : chr "anyMissing()"
   $ m0: logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ...
   $ m1: logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ...
   $ m2: logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ...
  List of 4
   $   : chr "all()"
   $ m0: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ...
   $ m1: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ...
   $ m2: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ...
  List of 4
   $   : chr "any()"
   $ m0: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ...
   $ m1: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ...
   $ m2: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ...
  List of 4
   $   : chr "anyMissing()"
   $ m0: logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ...
   $ m1: logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ...
   $ m2: logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ...
  List of 4
   $   : chr "all()"
   $ m0: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ...
   $ m1: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ...
   $ m2: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ...
  List of 4
   $   : chr "any()"
   $ m0: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ...
   $ m1: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ...
   $ m2: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ...
  List of 4
   $   : chr "anyMissing()"
   $ m0: logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ...
   $ m1: logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ...
   $ m2: logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ...
  List of 4
   $   : chr "all()"
   $ m0: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ...
   $ m1: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ...
   $ m2: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ...
  List of 4
   $   : chr "any()"
   $ m0: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ...
   $ m1: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ...
   $ m2: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ...
  List of 4
   $   : chr "anyMissing()"
   $ m0: logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ...
   $ m1: logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ...
   $ m2: logi [1:10] FALSE FALSE FALSE FALSE FALSE FALSE ...
  List of 4
   $   : chr "all()"
   $ m0: Named logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ...
    ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ...
   $ m1: Named logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ...
    ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ...
   $ m2: Named logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ...
    ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ...
  List of 4
   $   : chr "any()"
   $ m0: Named logi [1:10] TRUE NA TRUE FALSE TRUE TRUE ...
    ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ...
   $ m1: Named logi [1:10] TRUE NA TRUE FALSE TRUE TRUE ...
    ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ...
   $ m2: Named logi [1:10] TRUE NA TRUE FALSE TRUE TRUE ...
    ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ...
  List of 4
   $   : chr "anyMissing()"
   $ m0: Named logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ...
    ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ...
   $ m1: Named logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ...
    ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ...
   $ m2: Named logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ...
    ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ...
  List of 4
   $   : chr "all()"
   $ m0: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ...
   $ m1: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ...
   $ m2: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ...
  List of 4
   $   : chr "any()"
   $ m0: logi [1:10] TRUE NA TRUE FALSE TRUE TRUE ...
   $ m1: logi [1:10] TRUE NA TRUE FALSE TRUE TRUE ...
   $ m2: logi [1:10] TRUE NA TRUE FALSE TRUE TRUE ...
  List of 4
   $   : chr "anyMissing()"
   $ m0: logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ...
   $ m1: logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ...
   $ m2: logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ...
  List of 4
   $   : chr "all()"
   $ m0: Named logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ...
    ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ...
   $ m1: Named logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ...
    ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ...
   $ m2: Named logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ...
    ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ...
  List of 4
   $   : chr "any()"
   $ m0: Named logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ...
    ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ...
   $ m1: Named logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ...
    ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ...
   $ m2: Named logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ...
    ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ...
  List of 4
   $   : chr "anyMissing()"
   $ m0: Named logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ...
    ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ...
   $ m1: Named logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ...
    ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ...
   $ m2: Named logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ...
    ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ...
  List of 4
   $   : chr "all()"
   $ m0: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ...
   $ m1: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ...
   $ m2: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ...
  List of 4
   $   : chr "any()"
   $ m0: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ...
   $ m1: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ...
   $ m2: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ...
  List of 4
   $   : chr "anyMissing()"
   $ m0: logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ...
   $ m1: logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ...
   $ m2: logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ...
  List of 4
   $   : chr "all()"
   $ m0: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ...
   $ m1: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ...
   $ m2: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ...
  List of 4
   $   : chr "any()"
   $ m0: logi [1:10] TRUE NA TRUE FALSE TRUE TRUE ...
   $ m1: logi [1:10] TRUE NA TRUE FALSE TRUE TRUE ...
   $ m2: logi [1:10] TRUE NA TRUE FALSE TRUE TRUE ...
  List of 4
   $   : chr "anyMissing()"
   $ m0: logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ...
   $ m1: logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ...
   $ m2: logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ...
  List of 4
   $   : chr "all()"
   $ m0: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ...
   $ m1: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ...
   $ m2: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ...
  List of 4
   $   : chr "any()"
   $ m0: logi [1:10] TRUE NA TRUE FALSE TRUE TRUE ...
   $ m1: logi [1:10] TRUE NA TRUE FALSE TRUE TRUE ...
   $ m2: logi [1:10] TRUE NA TRUE FALSE TRUE TRUE ...
  List of 4
   $   : chr "anyMissing()"
   $ m0: logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ...
   $ m1: logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ...
   $ m2: logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ...
  List of 4
   $   : chr "all()"
   $ m0: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ...
   $ m1: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ...
   $ m2: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ...
  List of 4
   $   : chr "any()"
   $ m0: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ...
   $ m1: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ...
   $ m2: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ...
  List of 4
   $   : chr "anyMissing()"
   $ m0: logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ...
   $ m1: logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ...
   $ m2: logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ...
  List of 4
   $   : chr "all()"
   $ m0: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ...
   $ m1: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ...
   $ m2: logi [1:10] FALSE FALSE TRUE FALSE FALSE FALSE ...
  List of 4
   $   : chr "any()"
   $ m0: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ...
   $ m1: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ...
   $ m2: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ...
  List of 4
   $   : chr "anyMissing()"
   $ m0: logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ...
   $ m1: logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ...
   $ m2: logi [1:10] FALSE TRUE FALSE FALSE FALSE FALSE ...
  List of 4
   $   : chr "all()"
   $ m0: Named logi [1:10] FALSE NA NA FALSE FALSE FALSE ...
    ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ...
   $ m1: Named logi [1:10] FALSE NA NA FALSE FALSE FALSE ...
    ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ...
   $ m2: Named logi [1:10] FALSE NA NA FALSE FALSE FALSE ...
    ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ...
  List of 4
   $   : chr "any()"
   $ m0: Named logi [1:10] TRUE NA TRUE NA TRUE TRUE ...
    ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ...
   $ m1: Named logi [1:10] TRUE NA TRUE NA TRUE TRUE ...
    ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ...
   $ m2: Named logi [1:10] TRUE NA TRUE NA TRUE TRUE ...
    ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ...
  List of 4
   $   : chr "anyMissing()"
   $ m0: Named logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ...
    ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ...
   $ m1: Named logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ...
    ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ...
   $ m2: Named logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ...
    ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ...
  List of 4
   $   : chr "all()"
   $ m0: logi [1:10] FALSE NA NA FALSE FALSE FALSE ...
   $ m1: logi [1:10] FALSE NA NA FALSE FALSE FALSE ...
   $ m2: logi [1:10] FALSE NA NA FALSE FALSE FALSE ...
  List of 4
   $   : chr "any()"
   $ m0: logi [1:10] TRUE NA TRUE NA TRUE TRUE ...
   $ m1: logi [1:10] TRUE NA TRUE NA TRUE TRUE ...
   $ m2: logi [1:10] TRUE NA TRUE NA TRUE TRUE ...
  List of 4
   $   : chr "anyMissing()"
   $ m0: logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ...
   $ m1: logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ...
   $ m2: logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ...
  List of 4
   $   : chr "all()"
   $ m0: Named logi [1:10] FALSE TRUE TRUE FALSE FALSE FALSE ...
    ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ...
   $ m1: Named logi [1:10] FALSE TRUE TRUE FALSE FALSE FALSE ...
    ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ...
   $ m2: Named logi [1:10] FALSE TRUE TRUE FALSE FALSE FALSE ...
    ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ...
  List of 4
   $   : chr "any()"
   $ m0: Named logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ...
    ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ...
   $ m1: Named logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ...
    ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ...
   $ m2: Named logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ...
    ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ...
  List of 4
   $   : chr "anyMissing()"
   $ m0: Named logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ...
    ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ...
   $ m1: Named logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ...
    ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ...
   $ m2: Named logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ...
    ..- attr(*, "names")= chr [1:10] "a" "b" "c" "d" ...
  List of 4
   $   : chr "all()"
   $ m0: logi [1:10] FALSE TRUE TRUE FALSE FALSE FALSE ...
   $ m1: logi [1:10] FALSE TRUE TRUE FALSE FALSE FALSE ...
   $ m2: logi [1:10] FALSE TRUE TRUE FALSE FALSE FALSE ...
  List of 4
   $   : chr "any()"
   $ m0: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ...
   $ m1: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ...
   $ m2: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ...
  List of 4
   $   : chr "anyMissing()"
   $ m0: logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ...
   $ m1: logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ...
   $ m2: logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ...
  List of 4
   $   : chr "all()"
   $ m0: logi [1:10] FALSE NA NA FALSE FALSE FALSE ...
   $ m1: logi [1:10] FALSE NA NA FALSE FALSE FALSE ...
   $ m2: logi [1:10] FALSE NA NA FALSE FALSE FALSE ...
  List of 4
   $   : chr "any()"
   $ m0: logi [1:10] TRUE NA TRUE NA TRUE TRUE ...
   $ m1: logi [1:10] TRUE NA TRUE NA TRUE TRUE ...
   $ m2: logi [1:10] TRUE NA TRUE NA TRUE TRUE ...
  List of 4
   $   : chr "anyMissing()"
   $ m0: logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ...
   $ m1: logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ...
   $ m2: logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ...
  List of 4
   $   : chr "all()"
   $ m0: logi [1:10] FALSE NA NA FALSE FALSE FALSE ...
   $ m1: logi [1:10] FALSE NA NA FALSE FALSE FALSE ...
   $ m2: logi [1:10] FALSE NA NA FALSE FALSE FALSE ...
  List of 4
   $   : chr "any()"
   $ m0: logi [1:10] TRUE NA TRUE NA TRUE TRUE ...
   $ m1: logi [1:10] TRUE NA TRUE NA TRUE TRUE ...
   $ m2: logi [1:10] TRUE NA TRUE NA TRUE TRUE ...
  List of 4
   $   : chr "anyMissing()"
   $ m0: logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ...
   $ m1: logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ...
   $ m2: logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ...
  List of 4
   $   : chr "all()"
   $ m0: logi [1:10] FALSE TRUE TRUE FALSE FALSE FALSE ...
   $ m1: logi [1:10] FALSE TRUE TRUE FALSE FALSE FALSE ...
   $ m2: logi [1:10] FALSE TRUE TRUE FALSE FALSE FALSE ...
  List of 4
   $   : chr "any()"
   $ m0: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ...
   $ m1: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ...
   $ m2: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ...
  List of 4
   $   : chr "anyMissing()"
   $ m0: logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ...
   $ m1: logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ...
   $ m2: logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ...
  List of 4
   $   : chr "all()"
   $ m0: logi [1:10] FALSE TRUE TRUE FALSE FALSE FALSE ...
   $ m1: logi [1:10] FALSE TRUE TRUE FALSE FALSE FALSE ...
   $ m2: logi [1:10] FALSE TRUE TRUE FALSE FALSE FALSE ...
  List of 4
   $   : chr "any()"
   $ m0: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ...
   $ m1: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ...
   $ m2: logi [1:10] TRUE FALSE TRUE FALSE TRUE TRUE ...
  List of 4
   $   : chr "anyMissing()"
   $ m0: logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ...
   $ m1: logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ...
   $ m2: logi [1:10] TRUE TRUE TRUE TRUE TRUE TRUE ...
  > 
  > 
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > # Data type: integer
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > x <- matrix(rep(1:6, length.out = 4 * 5), nrow = 4L, ncol = 5L)
  > x[2, ] <- 7L
  > x[3, 1] <- 7L
  > x[2:3, 3:4] <- NA_integer_
  > 
  > # To check names attribute
  > dimnames <- list(letters[1:4], LETTERS[1:5])
  > 
  > # Row/column counts
  > value <- 7L
  > 
  > # Test with and without dimnames on x
  > for (setDimnames in c(TRUE, FALSE)) {
  +   dimnames(x) <- if (setDimnames) dimnames else NULL
  +   for (na.rm in c(FALSE, TRUE)) {
  +     # Check names attribute
  +     for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) {
  +       r0 <- rowAlls_R(x, value = value, na.rm = na.rm, useNames = useNames)
  +       r1 <- rowAlls(x, value = value, na.rm = na.rm, useNames = useNames)
  +       r2 <- colAlls(t(x), value = value, na.rm = na.rm, useNames = useNames)
  +       stopifnot(identical(r1, r0))
  +       stopifnot(identical(r2, r1))
  +       if (!is.na(useNames) && !useNames && !setDimnames) {
  +         for (rr in seq_len(nrow(x))) {
  +           c <- allValue(x[rr, ], value = value, na.rm = na.rm)
  +           stopifnot(identical(c, r1[rr]))
  +           c <- allValue(x[rr, ], value = value, na.rm = na.rm)
  +           stopifnot(identical(c, r1[rr]))
  +         }
  +       }
  + 
  +       r0 <- rowAnys_R(x, value = value, na.rm = na.rm, useNames = useNames)
  +       r1 <- rowAnys(x, value = value, na.rm = na.rm, useNames = useNames)
  +       r2 <- colAnys(t(x), value = value, na.rm = na.rm, useNames = useNames)
  +       stopifnot(identical(r1, r0))
  +       stopifnot(identical(r2, r1))        
  +       if (!is.na(useNames) && !useNames && !setDimnames) {
  +         for (rr in seq_len(nrow(x))) {
  +           c <- anyValue(x[rr, ], value = value, na.rm = na.rm)
  +           stopifnot(identical(c, r1[rr]))
  +           c <- anyValue(x[rr, ], value = value, na.rm = na.rm)
  +           stopifnot(identical(c, r1[rr]))
  +         }
  +       }
  +     }
  +   }
  + }
  > 
  > 
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > # rowAlls(x) et al. on numeric 'x' with logical 'value'
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > x <- matrix(0, nrow = 4L, ncol = 5L)
  > x[2:4, 2] <- (1:3) / 4
  > x[2, 2:4] <- (1:3) / 4
  > x[3:4, 3] <- (3:4) / 4
  > x[3, 3:4] <- (3:4) / 4
  > x[1:4, 5] <- (1:4) / 5
  > x[4, 4] <- NA_real_
  > 
  > # To check names attribute
  > dimnames <- list(letters[1:4], LETTERS[1:5])
  > 
  > for (value in c(TRUE, FALSE)) {
  +   for (na.rm in c(FALSE, TRUE)) {
  +     y0 <- suppressWarnings(apply(x, MARGIN = 1L, FUN = function(e) any(as.logical(e) == value, na.rm = na.rm)))
  +     y <- rowAnys(x, na.rm = na.rm, value = value)
  +     stopifnot(identical(y, y0))
  +     # Check names attribute
  +     dimnames(x) <- dimnames
  +     y <- rowAnys(x, na.rm = na.rm, value = value, useNames = FALSE)
  +     stopifnot(all.equal(y, y0))
  +     y0 <- suppressWarnings(apply(x, MARGIN = 1L, FUN = function(e) any(as.logical(e) == value, na.rm = na.rm)))
  +     y <- rowAnys(x, na.rm = na.rm, value = value, useNames = TRUE)
  +     stopifnot(all.equal(y, y0))
  +     dimnames(x) <- NULL
  +   
  +     y0 <- suppressWarnings(apply(x, MARGIN = 2L, FUN = function(e) any(as.logical(e) == value, na.rm = na.rm)))
  +     y <- colAnys(x, na.rm = na.rm, value = value)
  +     stopifnot(identical(y, y0))
  +     # Check names attribute
  +     dimnames(x) <- dimnames
  +     y <- colAnys(x, na.rm = na.rm, value = value, useNames = FALSE)
  +     stopifnot(all.equal(y, y0))
  +     y0 <- suppressWarnings(apply(x, MARGIN = 2L, FUN = function(e) any(as.logical(e) == value, na.rm = na.rm)))
  +     y <- colAnys(x, na.rm = na.rm, value = value, useNames = TRUE)
  +     stopifnot(all.equal(y, y0))
  +     dimnames(x) <- NULL
  +   
  +     y0 <- suppressWarnings(apply(x, MARGIN = 1L, FUN = function(e) all(as.logical(e) == value, na.rm = na.rm)))
  +     y <- rowAlls(x, na.rm = na.rm, value = value)
  +     stopifnot(identical(y, y0))
  +     # Check names attribute
  +     dimnames(x) <- dimnames
  +     y <- rowAlls(x, na.rm = na.rm, value = value, useNames = FALSE)
  +     stopifnot(all.equal(y, y0))  
  +     y0 <- suppressWarnings(apply(x, MARGIN = 1L, FUN = function(e) all(as.logical(e) == value, na.rm = na.rm)))
  +     y <- rowAlls(x, na.rm = na.rm, value = value, useNames = TRUE)
  +     stopifnot(all.equal(y, y0))    
  +     dimnames(x) <- NULL
  +   
  +     y0 <- suppressWarnings(apply(x, MARGIN = 2L, FUN = function(e) all(as.logical(e) == value, na.rm = na.rm)))
  +     y <- colAlls(x, na.rm = na.rm, value = value)
  +     stopifnot(identical(y, y0))
  +     print(y0)
  +     # Check names attribute
  +     dimnames(x) <- dimnames
  +     y <- colAlls(x, na.rm = na.rm, value = value, useNames = FALSE)
  +     stopifnot(all.equal(y, y0))     
  +     y0 <- suppressWarnings(apply(x, MARGIN = 2L, FUN = function(e) all(as.logical(e) == value, na.rm = na.rm)))
  +     y <- colAlls(x, na.rm = na.rm, value = value, useNames = TRUE)
  +     stopifnot(all.equal(y, y0))     
  +     dimnames(x) <- NULL
  +   } ## for (na.rm ...)
  + } ## for(value ...)
  [1] FALSE FALSE FALSE FALSE  TRUE
  [1] FALSE FALSE FALSE FALSE  TRUE
  [1]  TRUE FALSE FALSE FALSE FALSE
  [1]  TRUE FALSE FALSE FALSE FALSE
  > 
  > 
  > 
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > # Data type: character (not sure if this should be supported)
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > all_R <- function(x, value = TRUE, ...) {
  +   if (is.na(value)) {
  +     all(is.na(x), ...)
  +   } else {
  +     all(x == value, ...)
  +   }
  + }
  > 
  > any_R <- function(x, value = TRUE, ...) {
  +   if (is.na(value)) {
  +     any(is.na(x), ...)
  +   } else {
  +     any(x == value, ...)
  +   }
  + }
  > 
  > x <- matrix(rep(letters, length.out = 10 * 5), nrow = 10L, ncol = 5L)
  > x[2, ] <- "g"
  > x[2:4, 3:4] <- NA_character_
  > 
  > # To check names attribute
  > dimnames <- list(letters[1:10], LETTERS[1:5])
  > 
  > # Test with and without dimnames on x
  > for (setDimnames in c(TRUE, FALSE)) {
  +   dimnames(x) <- if (setDimnames) dimnames else NULL
  + 
  +   # Row/column counts
  +   for (value in c("g", NA_character_)) {
  +     for (na.rm in c(FALSE, TRUE)) {
  +       # Check names attribute
  +       for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) {
  +         r0 <- rowAlls_R(x, value = value, na.rm = na.rm, useNames = useNames)
  +         r1 <- rowAlls(x, value = value, na.rm = na.rm, useNames = useNames)
  +         r2 <- colAlls(t(x), value = value, na.rm = na.rm, useNames = useNames)
  +         stopifnot(identical(r1, r0))
  +         stopifnot(identical(r2, r1))
  +         if (!is.na(useNames) && !useNames && !setDimnames) {
  +           for (rr in seq_len(nrow(x))) {
  +             c0 <- all_R(x[rr, ], value, na.rm = na.rm)
  +             c <- allValue(x[rr, ], value = value, na.rm = na.rm)
  +             stopifnot(identical(c, r1[rr]))
  +             stopifnot(identical(c, c0))
  +           }
  +         }
  +         
  +         r0 <- rowAnys_R(x, value = value, na.rm = na.rm, useNames = useNames)
  +         r1 <- rowAnys(x, value = value, na.rm = na.rm, useNames = useNames)
  +         r2 <- colAnys(t(x), value = value, na.rm = na.rm, useNames = useNames)
  +         stopifnot(identical(r1, r0))
  +         stopifnot(identical(r2, r1))        
  +         if (!is.na(useNames) && !useNames && !setDimnames) {
  +           for (rr in seq_len(nrow(x))) {
  +             c0 <- any_R(x[rr, ], value, na.rm = na.rm)
  +             c <- anyValue(x[rr, ], value = value, na.rm = na.rm)
  +             stopifnot(identical(c, c0))
  +             stopifnot(identical(c, r1[rr]))
  +           }
  +         }
  +       }
  +     }
  +   }
  + }
  > 
  > 
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > # NA 0 test
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > x <- matrix(0, nrow = 3L, ncol = 3L)
  > x[1, ] <- c(NA_real_, NA_real_, 0)
  > x[3, ] <- c(1, 0, 1)
  > 
  > dimnames <- list(letters[1:3], LETTERS[1:3])
  > 
  > # Test with and without dimnames on x
  > for (setDimnames in c(TRUE, FALSE)) {
  +   dimnames(x) <- if (setDimnames) dimnames else NULL
  +   # Check names attribute
  +   for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) {
  +     r0 <- rowAnys_R(x, value = 0, useNames = useNames)
  +     r1 <- rowAnys(x, value = 0, useNames = useNames)
  +     stopifnot(identical(r0, r1))
  +   }
  + }
  > 
  > proc.time()
     user  system elapsed 
     0.64    0.06    0.68 
Running the tests in 'tests/rowAvgsPerColSet_subset.R' failed.
Complete output:
  > library("matrixStats")
  > 
  > # - - - - - - - - - - - - - - - - - - - - - - - - - -
  > # Subsetted tests
  > # - - - - - - - - - - - - - - - - - - - - - - - - - -
  > source("utils/validateIndicesFramework.R")
  > x <- matrix(runif(6 * 6, min = -6, max = 6), nrow = 6, ncol = 6)
  > #W <- matrix(runif(6 * 6, min = -6, max = 6), nrow = 6, ncol = 6)
  > for (rows in index_cases) {
  +   for (cols in index_cases) {
  +     if (is.null(rows)) {
  +       rows <- seq_len(nrow(x))
  +       rows_finite <- rows
  +     } else {
  +       rows_finite <- rows[is.finite(rows)]
  +     }
  + 
  +     if (is.null(cols)) {
  +       cols <- seq_len(ncol(x))
  +       cols_finite <- cols
  +     } else {
  +       cols_finite <- cols[is.finite(cols)]
  +     }
  + 
  +     suppressWarnings({
  +       actual <- tryCatch({
  +         rowAvgsPerColSet(x, rows = rows, S = matrix(cols, ncol = 1),
  +                          FUN = rowMeans)
  +       }, error = function(c) "error")
  +       expect <- tryCatch({
  +         rowMeans(x[rows, cols_finite, drop = FALSE], na.rm = TRUE)
  +       }, error = function(c) "error")
  +     })
  +     stopifnot(all.equal(as.vector(actual), expect))
  + 
  +     suppressWarnings({
  +       actual <- tryCatch({
  +         colAvgsPerRowSet(x, cols = cols, S = matrix(rows, ncol = 1),
  +                          FUN = colMeans)
  +       }, error = function(c) "error")
  +       expect <- tryCatch({
  +         colMeans(x[rows_finite, cols, drop = FALSE], na.rm = TRUE)
  +       }, error = function(c) "error")
  +     })
  +     stopifnot(all.equal(as.vector(actual), expect))
  +   }
  + }
  > 
  > proc.time()
     user  system elapsed 
     0.48    0.04    0.51 
Running the tests in 'tests/rowCounts.R' failed.
Complete output:
  > library("matrixStats")
  > 
  > rowCounts_R <- function(x, value = TRUE, na.rm = FALSE, ...) {
  +   if (is.na(value)) {
  +     counts <- apply(x, MARGIN = 1L, FUN = function(x)
  +       sum(is.na(x))
  +     )
  +   } else {
  +     counts <- apply(x, MARGIN = 1L, FUN = function(x)
  +       sum(x == value, na.rm = na.rm)
  +     )
  +   }
  +   # Preserve names attribute
  +   names <- names(counts)  
  +   counts <- as.integer(counts)
  +   if (isTRUE(useNames) && !is.null(names)) names(counts) <- names
  +   counts
  + }
  > 
  > 
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > # Data type: integer and numeric
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > for (mode in c("integer", "double")) {
  +   x <- matrix(runif(10 * 5, min = -3, max = 3), nrow = 10L, ncol = 5L)
  +   x[sample.int(length(x), size = 7L)] <- 0
  +   storage.mode(x) <- mode
  +   
  +   dimnames = list(letters[1:10], LETTERS[1:5])
  +   
  +   # Test with and without dimnames on x
  +   for (setDimnames in c(TRUE, FALSE)) {
  +     if (setDimnames) dimnames(x) <- dimnames
  +     else dimnames(x) <- NULL    
  +     for (na.rm in c(FALSE, TRUE)) {
  +       # Check names attribute
  +       for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) {
  +         # Count zeros
  +         r0 <- rowCounts_R(x, value = 0, na.rm = na.rm, useNames = useNames)
  +         r1 <- rowCounts(x, value = 0, na.rm = na.rm, useNames = useNames)
  +         r2 <- colCounts(t(x), value = 0, na.rm = na.rm, useNames = useNames)
  +         stopifnot(identical(r1, r0))
  +         stopifnot(identical(r2, r0))
  +         
  +         # Count NAs
  +         r0 <- rowCounts_R(x, value = NA, na.rm = na.rm, useNames = useNames)
  +         r1 <- rowCounts(x, value = NA, na.rm = na.rm, useNames = useNames)
  +         r2 <- colCounts(t(x), value = NA, na.rm = na.rm, useNames = useNames)
  +         stopifnot(identical(r1, r0))
  +         stopifnot(identical(r2, r0))
  +         
  +         if (mode == "integer") {
  +           ux <- unique(as.vector(x))
  +           r0 <- r1 <- r2 <- integer(nrow(x))
  +           for (value in ux) {
  +             r0 <- r0 + rowCounts_R(x, value = value, na.rm = na.rm, useNames = useNames)
  +             r1 <- r1 + rowCounts(x, value = value, na.rm = na.rm, useNames = useNames)
  +             r2 <- r2 + colCounts(t(x), value = value, na.rm = na.rm, useNames = useNames)
  +             stopifnot(identical(r1, r0))
  +             stopifnot(identical(r2, r0))
  +           }
  +           stopifnot(all(r0 == ncol(x)))
  +         } # if (mode == "integer")
  +       } # for (useNames ...)
  +     } # for (na.rm ...)
  +   } # for (setDimnames ...)
  + } # for (mode ...)
  > 
  > 
  > # All NAs
  > na_list <- list(NA_integer_, NA_real_, NaN)
  > for (na_value in na_list) {
  +   x <- matrix(na_value, nrow = 10L, ncol = 5L)
  +   # Test with and without dimnames on x
  +   for (setDimnames in c(TRUE, FALSE)) {
  +     if (setDimnames) dimnames(x) <- dimnames
  +     else dimnames(x) <- NULL    
  +     for (na.rm in c(FALSE, TRUE)) {
  +       # Check names attribute
  +       for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) {
  +         r0 <- rowCounts_R(x, na.rm = na.rm, useNames = useNames)
  +         r1 <- rowCounts(x, na.rm = na.rm, useNames = useNames)
  +         r2 <- colCounts(t(x), na.rm = na.rm, useNames = useNames)
  +         stopifnot(identical(r1, r0))
  +         stopifnot(identical(r2, r0))
  +         
  +         # Count NAs
  +         r0 <- rowCounts_R(x, value = NA, na.rm = na.rm, useNames = useNames)
  +         r1 <- rowCounts(x, value = NA, na.rm = na.rm, useNames = useNames)
  +         r2 <- colCounts(t(x), value = NA, na.rm = na.rm, useNames = useNames)
  +         stopifnot(all(r0 == ncol(x)))
  +         stopifnot(identical(r1, r0))
  +         stopifnot(identical(r2, r0))
  +       }
  +     }
  +   }
  + } # for (na_value ...)
  > 
  > 
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > # Data type: logical
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > x <- matrix(FALSE, nrow = 10L, ncol = 4L)
  > x[7:8, 2:3] <- TRUE
  > x[1:3, ] <- TRUE
  > x[, 1] <- TRUE
  > x[4, ] <- FALSE
  > x[, 4] <- FALSE
  > x[2, ] <- FALSE
  > x[3, ] <- TRUE
  > 
  > # To check names attribute
  > dimnames <- list(letters[1:10], LETTERS[1:4])
  > 
  > # Test with and without dimnames on x
  > for (setDimnames in c(TRUE, FALSE)) {
  +   if (setDimnames) dimnames(x) <- dimnames
  +   else dimnames(x) <- NULL
  +   # Row/column counts
  +   for (na.rm in c(FALSE, TRUE)) {
  +     # Check names attribute
  +     for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) {
  +       r0 <- rowCounts_R(x, na.rm = na.rm, useNames = useNames)
  +       r1 <- rowCounts(x, na.rm = na.rm, useNames = useNames)
  +       r2 <- colCounts(t(x), na.rm = na.rm, useNames = useNames)
  +       stopifnot(identical(r1, r0))
  +       stopifnot(identical(r2, r0))
  +       
  +       r_true <- rowCounts(x, value = TRUE, na.rm = na.rm, useNames = useNames)
  +       r_false <- rowCounts(x, value = FALSE, na.rm = na.rm, useNames = useNames)
  +       stopifnot(r_true + r_false == ncol(x))
  +       
  +       c_true <- colCounts(x, value = TRUE, na.rm = na.rm, useNames = useNames)
  +       c_false <- colCounts(x, value = FALSE, na.rm = na.rm, useNames = useNames)
  +       stopifnot(c_true + c_false == nrow(x))
  +       
  +       # Count NAs
  +       r0 <- rowCounts_R(x, value = NA, na.rm = na.rm, useNames = useNames)
  +       r1 <- rowCounts(x, value = NA, na.rm = na.rm, useNames = useNames)
  +       r2 <- colCounts(t(x), value = NA, na.rm = na.rm, useNames = useNames)
  +       stopifnot(identical(r1, r0))
  +       stopifnot(identical(r2, r0))
  +     }
  +   }
  + }
  > 
  > 
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > # Data type: character (not sure if this should be supported)
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > x <- matrix(rep(letters, length.out = 10 * 5), nrow = 10L, ncol = 5L)
  > x[2:3, 3:4] <- NA_character_
  > 
  > # Row/column counts
  > for (na.rm in c(FALSE, TRUE)) {
  +   for (value in c("g", NA_character_)) {
  +     r0 <- rowCounts_R(x, value = value, na.rm = na.rm)
  +     r1 <- rowCounts(x, value = value, na.rm = na.rm)
  +     r2 <- colCounts(t(x), value = value, na.rm = na.rm)
  +     stopifnot(identical(r1, r0))
  +     stopifnot(identical(r2, r0))
  + 
  +     c <- count(x[1, ], value = value, na.rm = na.rm)
  +     stopifnot(identical(c, r1[1]))
  + 
  +     c <- count(x[2, ], value = value, na.rm = na.rm)
  +     stopifnot(identical(c, r1[2]))
  +   }
  + }
  > 
  > # NA row
  > x <- matrix(0, nrow = 2L, ncol = 2L)
  > x[1, ] <- NA_integer_
  > 
  > dimnames <- list(letters[1:2], LETTERS[1:2])
  > 
  > # Test with and without dimnames on x
  > for (setDimnames in c(TRUE, FALSE)) {
  +   if (setDimnames) dimnames(x) <- dimnames
  +   else dimnames(x) <- NULL    
  +   # Check names attribute
  +   for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) {
  +     r0 <- rowCounts(x, value = 0, useNames = useNames)
  +     r1 <- rowCounts_R(x, value = 0, useNames = useNames)
  +     stopifnot(identical(r0, r1))
  +   }
  + }
  > 
  > proc.time()
     user  system elapsed 
     0.37    0.04    0.40 
Running the tests in 'tests/rowCumprods_subset.R' failed.
Complete output:
  > library("matrixStats")
  > 
  > rowCumprods_R <- function(x, ..., useNames = NA) {
  +   suppressWarnings({
  +     y <- t(apply(x, MARGIN = 1L, FUN = cumprod))
  +   })
  + 
  +   # Preserve dimnames attribute?
  +   dim(y) <- dim(x)
  +   dimnames(y) <- if (isTRUE(useNames)) dimnames(x) else NULL
  +   
  +   y
  + }
  > 
  > 
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > # Subsetted tests
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > source("utils/validateIndicesFramework.R")
  > x <- matrix(runif(6 * 6, min = -3, max = 3), nrow = 6, ncol = 6)
  > storage.mode(x) <- "integer"
  > 
  > # To check dimnames attribute
  > dimnames <- list(letters[1:6], LETTERS[1:6])
  > 
  > # Test with and without dimnames on x
  > for (setDimnames in c(TRUE, FALSE)) {
  +   if (setDimnames) dimnames(x) <- dimnames
  +   else dimnames(x) <- NULL
  +   for (rows in index_cases) {
  +     for (cols in index_cases) {
  +       # Check names attribute
  +       for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) {
  +         validateIndicesTestMatrix(x, rows, cols,
  +                                   ftest = rowCumprods, fsure = rowCumprods_R, useNames = useNames)
  +         validateIndicesTestMatrix(x, rows, cols,
  +                                   ftest = function(x, rows, cols, ..., useNames) {
  +           t(colCumprods(t(x), rows = cols, cols = rows, useNames = useNames))
  +         }, fsure = rowCumprods_R, useNames = useNames)
  +       }
  +     }
  +   }
  + }
  > 
  > proc.time()
     user  system elapsed 
     1.29    0.09    1.39 
Running the tests in 'tests/rowCumsums.R' failed.
Complete output:
  > library("matrixStats")
  > 
  > rowCumsums_R <- function(x, ..., useNames = NA) {
  +   suppressWarnings({
  +     y <- t(apply(x, MARGIN = 1L, FUN = cumsum))
  +   })
  +   
  +   # Preserve dimnames attribute?
  +   dim(y) <- dim(x)
  +   dimnames(y) <- if (isTRUE(useNames)) dimnames(x) else NULL
  +   
  +   y
  + }
  > 
  > 
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > # With and without some NAs
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > dimnames <- list(letters[1:10], LETTERS[1:5]) # to check dimnames attribute
  > for (mode in c("logical", "integer", "double")) {
  +   for (add_na in c(FALSE, TRUE)) {
  +     cat("add_na = ", add_na, "\n", sep = "")
  + 
  +     x <- matrix(1:50, nrow = 10L, ncol = 5L)
  +     if (add_na) {
  +       x[3:7, c(2, 4)] <- NA_real_
  +     }
  +     cat("mode: ", mode, "\n", sep = "")
  +     storage.mode(x) <- mode
  +     str(x)
  +     
  +     # Test with and without dimnames on x
  +     for (setDimnames in c(TRUE, FALSE)) {
  +       if (setDimnames) dimnames(x) <- dimnames
  +       else dimnames(x) <- NULL    
  +       # Check names attribute
  +       for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) {
  +         # Row/column ranges
  +         r0 <- rowCumsums_R(x, useNames = useNames)
  +         r1 <- rowCumsums(x, useNames = useNames)
  +         r2 <- t(colCumsums(t(x), useNames = useNames))
  +         stopifnot(all.equal(r1, r2))
  +         stopifnot(all.equal(r1, r0))
  +         stopifnot(all.equal(r2, r0))
  +       } # for (useNames ...)
  +     } # for (setDimnames ...)
  +   } # for (add_na ...)
  + }
  add_na = FALSE
  mode: logical
   logi [1:10, 1:5] TRUE TRUE TRUE TRUE TRUE TRUE ...
  add_na = TRUE
  mode: logical
   logi [1:10, 1:5] TRUE TRUE TRUE TRUE TRUE TRUE ...
  add_na = FALSE
  mode: integer
   int [1:10, 1:5] 1 2 3 4 5 6 7 8 9 10 ...
  add_na = TRUE
  mode: integer
   int [1:10, 1:5] 1 2 3 4 5 6 7 8 9 10 ...
  add_na = FALSE
  mode: double
   num [1:10, 1:5] 1 2 3 4 5 6 7 8 9 10 ...
  add_na = TRUE
  mode: double
   num [1:10, 1:5] 1 2 3 4 5 6 7 8 9 10 ...
  > 
  > 
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > # All NAs
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > for (mode in c("logical", "integer", "double")) {
  +   x <- matrix(NA_real_, nrow = 10L, ncol = 5L)
  +   cat("mode: ", mode, "\n", sep = "")
  +   storage.mode(x) <- mode
  +   str(x)
  +   
  +   # Test with and without dimnames on x
  +   for (setDimnames in c(TRUE, FALSE)) {
  +     if (setDimnames) dimnames(x) <- dimnames
  +     else dimnames(x) <- NULL    
  +     # Check names attribute
  +     for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) {
  +       # Row/column ranges
  +       r0 <- rowCumsums_R(x, useNames = useNames)
  +       r1 <- rowCumsums(x, useNames = useNames)
  +       r2 <- t(colCumsums(t(x), useNames = useNames))
  +       stopifnot(all.equal(r1, r2))
  +       stopifnot(all.equal(r1, r0))
  +       stopifnot(all.equal(r2, r0))
  +     } # for (useNames ...)
  +   } # for (setDimnames ...)
  + } # for (mode ...)
  mode: logical
   logi [1:10, 1:5] NA NA NA NA NA NA ...
  mode: integer
   int [1:10, 1:5] NA NA NA NA NA NA NA NA NA NA ...
  mode: double
   num [1:10, 1:5] NA NA NA NA NA NA NA NA NA NA ...
  > 
  > 
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > # A 1x1 matrix
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > dimnames <- list("a", "A") # to check dimnames attribute
  > for (mode in c("logical", "integer", "double")) {
  +   x <- matrix(0, nrow = 1L, ncol = 1L)
  +   cat("mode: ", mode, "\n", sep = "")
  +   storage.mode(x) <- mode
  +   str(x)
  + 
  +   r0 <- rowCumsums_R(x)
  +   r1 <- rowCumsums(x)
  +   r2 <- t(colCumsums(t(x)))
  +   stopifnot(all.equal(r1, r2))
  +   stopifnot(all.equal(r1, r0))
  +   stopifnot(all.equal(r2, r0))
  +   
  +   # Check dimnames attribute
  +   dimnames(x) <- dimnames
  +   # r0 <- rowCumsums_R(x)
  +   # > r0
  +   #        a
  +   #   [1,] 0
  +   r1 <- rowCumsums(x, useNames = TRUE)
  +   r2 <- t(colCumsums(t(x), useNames = TRUE))
  +   stopifnot(identical(dimnames(r1), dimnames))
  +   stopifnot(identical(dimnames(r2), dimnames))    
  +   dimnames(x) <- NULL
  + }
  mode: logical
   logi [1, 1] FALSE
  mode: integer
   int [1, 1] 0
  mode: double
   num [1, 1] 0
  > 
  > 
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > # Corner cases
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > names <- LETTERS[1:5] # to check dimnames attribute
  > for (mode in c("logical", "integer", "double")) {
  +   cat("mode: ", mode, "\n", sep = "")
  +   value <- 0
  +   storage.mode(value) <- mode
  +   value2 <- value
  +   if (mode == "logical") value2 <- 0L
  +   
  +   # A 0x0 matrix
  +   x <- matrix(value, nrow = 0L, ncol = 0L)
  +   str(x)
  +   r0 <- matrix(value2, nrow = nrow(x), ncol = ncol(x))
  +   r1 <- rowCumsums(x)
  +   r2 <- t(colCumsums(t(x)))
  +   stopifnot(all.equal(r1, r2))
  +   stopifnot(all.equal(r1, r0))
  +   stopifnot(all.equal(r2, r0))
  + 
  +   # A 0xK matrix
  +   x <- matrix(value, nrow = 0L, ncol = 5L)
  +   str(x)
  +   colnames <- LETTERS[1:5]
  +   # Test with and without dimnames on x
  +   for (setDimnames in c(TRUE, FALSE)) {
  +     if (setDimnames) colnames(x) <- colnames
  +     else dimnames(x) <- NULL
  +     # Check names attribute
  +     for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) {
  +       r0 <- rowCumsums_R(x, useNames = useNames)
  +       r1 <- rowCumsums(x, useNames = useNames)
  +       r2 <- t(rowCumsums(t(x), useNames = useNames))
  +       stopifnot(all.equal(r1, r2))
  +       stopifnot(all.equal(r1, r0))
  +       stopifnot(all.equal(r2, r0))
  +     } # for (useNames ...)
  +   } # for (setDimnames ...)
  + 
  +   # A Nx0 matrix
  +   x <- matrix(value, nrow = 5L, ncol = 0L)
  +   str(x)
  +   rownames <- LETTERS[1:5]
  +   # Test with and without dimnames on x
  +   for (setDimnames in c(TRUE, FALSE)) {
  +     if (setDimnames) rownames(x) <- rownames
  +     else dimnames(x) <- NULL
  +     # Check names attribute
  +     for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) {
  +       r0 <- rowCumsums_R(x, useNames = useNames)
  +       r1 <- rowCumsums(x, useNames = useNames)
  +       r2 <- t(rowCumsums(t(x), useNames = useNames))
  +       stopifnot(all.equal(r1, r2))
  +       stopifnot(all.equal(r1, r0))
  +       stopifnot(all.equal(r2, r0))
  +     } # for (useNames ...)
  +   } # for (setDimnames ...)
  + } # for (mode ...)
  mode: logical
   logi[0 , 0 ] 
   logi[0 , 1:5] 
   logi[1:5, 0 ] 
  mode: integer
   int[0 , 0 ] 
   int[0 , 1:5] 
   int[1:5, 0 ] 
  mode: double
   num[0 , 0 ] 
   num[0 , 1:5] 
   num[1:5, 0 ] 
  > 
  > proc.time()
     user  system elapsed 
     0.40    0.09    0.46 
Running the tests in 'tests/rowDiffs.R' failed.
Complete output:
  > library("matrixStats")
  > 
  > rowDiffs_R <- function(x, lag = 1L, differences = 1L, ..., useNames = NA) {
  +   ncol2 <- ncol(x) - lag * differences
  +   if (ncol2 <= 0) {
  +     y <- matrix(x[integer(0L)], nrow = nrow(x), ncol = 0L)
  +     # Preserve names attribute
  +     if (isTRUE(useNames) && !is.null(rownames(x))) rownames(y) <- rownames(x)
  +     return(y)
  +   }
  +   suppressWarnings({
  +     y <- apply(x, MARGIN = 1L, FUN = diff, lag = lag, differences = differences)
  +   })
  +   y <- t(y)
  +   
  +   # Preserve dimnames attribute
  +   dim(y) <- c(nrow(x), ncol2)
  +   if (isTRUE(useNames) && !is.null(dimnames(x))) {
  +     colnames <- colnames(x)
  +     if (!is.null(colnames)) {
  +       len <- length(colnames)
  +       colnames <- colnames[(len - ncol2 + 1):len]
  +     }
  +     dimnames(y) <- list(rownames(x), colnames)      
  +   }
  +   else dimnames(y) <- NULL
  +   
  +   y
  + }
  > 
  > 
  > set.seed(0x42)
  > 
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > # With and without some NAs
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > for (mode in c("integer", "double")) {
  +   cat("mode: ", mode, "\n", sep = "")
  + 
  +   for (add_na in c(FALSE, TRUE)) {
  +     cat("add_na = ", add_na, "\n", sep = "")
  + 
  +     x <- matrix(sample(10 * 8) + 0.1, nrow = 10L, ncol = 8L)
  +     if (add_na) {
  +       x[3:7, c(2, 4)] <- NA_real_
  +     }
  +     storage.mode(x) <- mode
  +     str(x)
  +     
  +     dimnames <- list(letters[1:10], LETTERS[1:8])
  + 
  +     # Test with and without dimnames on x
  +     for (setDimnames in c(TRUE, FALSE)) {
  +       if (setDimnames) dimnames(x) <- dimnames
  +       else dimnames(x) <- NULL
  +       # Check dimnames attribute
  +       for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) {
  +         for (lag in 1:4) {
  +           for (differences in 1:3) {
  +             cat(sprintf("mode: %s, lag = %d, differences = %d\n",
  +                         mode, lag, differences))
  +             # Row/column ranges
  +             r0 <- rowDiffs_R(x, lag = lag, differences = differences, useNames = useNames)
  +             r1 <- rowDiffs(x, lag = lag, differences = differences, useNames = useNames)
  +             r2 <- t(colDiffs(t(x), lag = lag, differences = differences, useNames = useNames))
  +             stopifnot(all.equal(r1, r0))
  +             stopifnot(all.equal(r2, r0))
  +             stopifnot(all.equal(r1, r2))
  +           }
  +         }
  +       } # for (useNames ...)
  +     } # for (setDimnames ...)
  +   } # for (add_na ...)
  + } # for (mode ...)
  mode: integer
  add_na = FALSE
   int [1:10, 1:8] 68 26 29 47 48 10 1 38 16 40 ...
  mode: integer, lag = 1, differences = 1
  mode: integer, lag = 1, differences = 2
  mode: integer, lag = 1, differences = 3
  mode: integer, lag = 2, differences = 1
  mode: integer, lag = 2, differences = 2
  mode: integer, lag = 2, differences = 3
  mode: integer, lag = 3, differences = 1
  mode: integer, lag = 3, differences = 2
  mode: integer, lag = 3, differences = 3
  mode: integer, lag = 4, differences = 1
  mode: integer, lag = 4, differences = 2
  mode: integer, lag = 4, differences = 3
  mode: integer, lag = 1, differences = 1
  mode: integer, lag = 1, differences = 2
  mode: integer, lag = 1, differences = 3
  mode: integer, lag = 2, differences = 1
  mode: integer, lag = 2, differences = 2
  mode: integer, lag = 2, differences = 3
  mode: integer, lag = 3, differences = 1
  mode: integer, lag = 3, differences = 2
  mode: integer, lag = 3, differences = 3
  mode: integer, lag = 4, differences = 1
  mode: integer, lag = 4, differences = 2
  mode: integer, lag = 4, differences = 3
  mode: integer, lag = 1, differences = 1
  mode: integer, lag = 1, differences = 2
  mode: integer, lag = 1, differences = 3
  mode: integer, lag = 2, differences = 1
  mode: integer, lag = 2, differences = 2
  mode: integer, lag = 2, differences = 3
  mode: integer, lag = 3, differences = 1
  mode: integer, lag = 3, differences = 2
  mode: integer, lag = 3, differences = 3
  mode: integer, lag = 4, differences = 1
  mode: integer, lag = 4, differences = 2
  mode: integer, lag = 4, differences = 3
  mode: integer, lag = 1, differences = 1
  mode: integer, lag = 1, differences = 2
  mode: integer, lag = 1, differences = 3
  mode: integer, lag = 2, differences = 1
  mode: integer, lag = 2, differences = 2
  mode: integer, lag = 2, differences = 3
  mode: integer, lag = 3, differences = 1
  mode: integer, lag = 3, differences = 2
  mode: integer, lag = 3, differences = 3
  mode: integer, lag = 4, differences = 1
  mode: integer, lag = 4, differences = 2
  mode: integer, lag = 4, differences = 3
  add_na = TRUE
   int [1:10, 1:8] 80 71 7 52 79 22 31 10 29 63 ...
  mode: integer, lag = 1, differences = 1
  mode: integer, lag = 1, differences = 2
  mode: integer, lag = 1, differences = 3
  mode: integer, lag = 2, differences = 1
  mode: integer, lag = 2, differences = 2
  mode: integer, lag = 2, differences = 3
  mode: integer, lag = 3, differences = 1
  mode: integer, lag = 3, differences = 2
  mode: integer, lag = 3, differences = 3
  mode: integer, lag = 4, differences = 1
  mode: integer, lag = 4, differences = 2
  mode: integer, lag = 4, differences = 3
  mode: integer, lag = 1, differences = 1
  mode: integer, lag = 1, differences = 2
  mode: integer, lag = 1, differences = 3
  mode: integer, lag = 2, differences = 1
  mode: integer, lag = 2, differences = 2
  mode: integer, lag = 2, differences = 3
  mode: integer, lag = 3, differences = 1
  mode: integer, lag = 3, differences = 2
  mode: integer, lag = 3, differences = 3
  mode: integer, lag = 4, differences = 1
  mode: integer, lag = 4, differences = 2
  mode: integer, lag = 4, differences = 3
  mode: integer, lag = 1, differences = 1
  mode: integer, lag = 1, differences = 2
  mode: integer, lag = 1, differences = 3
  mode: integer, lag = 2, differences = 1
  mode: integer, lag = 2, differences = 2
  mode: integer, lag = 2, differences = 3
  mode: integer, lag = 3, differences = 1
  mode: integer, lag = 3, differences = 2
  mode: integer, lag = 3, differences = 3
  mode: integer, lag = 4, differences = 1
  mode: integer, lag = 4, differences = 2
  mode: integer, lag = 4, differences = 3
  mode: integer, lag = 1, differences = 1
  mode: integer, lag = 1, differences = 2
  mode: integer, lag = 1, differences = 3
  mode: integer, lag = 2, differences = 1
  mode: integer, lag = 2, differences = 2
  mode: integer, lag = 2, differences = 3
  mode: integer, lag = 3, differences = 1
  mode: integer, lag = 3, differences = 2
  mode: integer, lag = 3, differences = 3
  mode: integer, lag = 4, differences = 1
  mode: integer, lag = 4, differences = 2
  mode: integer, lag = 4, differences = 3
  mode: double
  add_na = FALSE
   num [1:10, 1:8] 36.1 15.1 27.1 63.1 62.1 58.1 28.1 19.1 41.1 3.1 ...
  mode: double, lag = 1, differences = 1
  mode: double, lag = 1, differences = 2
  mode: double, lag = 1, differences = 3
  mode: double, lag = 2, differences = 1
  mode: double, lag = 2, differences = 2
  mode: double, lag = 2, differences = 3
  mode: double, lag = 3, differences = 1
  mode: double, lag = 3, differences = 2
  mode: double, lag = 3, differences = 3
  mode: double, lag = 4, differences = 1
  mode: double, lag = 4, differences = 2
  mode: double, lag = 4, differences = 3
  mode: double, lag = 1, differences = 1
  mode: double, lag = 1, differences = 2
  mode: double, lag = 1, differences = 3
  mode: double, lag = 2, differences = 1
  mode: double, lag = 2, differences = 2
  mode: double, lag = 2, differences = 3
  mode: double, lag = 3, differences = 1
  mode: double, lag = 3, differences = 2
  mode: double, lag = 3, differences = 3
  mode: double, lag = 4, differences = 1
  mode: double, lag = 4, differences = 2
  mode: double, lag = 4, differences = 3
  mode: double, lag = 1, differences = 1
  mode: double, lag = 1, differences = 2
  mode: double, lag = 1, differences = 3
  mode: double, lag = 2, differences = 1
  mode: double, lag = 2, differences = 2
  mode: double, lag = 2, differences = 3
  mode: double, lag = 3, differences = 1
  mode: double, lag = 3, differences = 2
  mode: double, lag = 3, differences = 3
  mode: double, lag = 4, differences = 1
  mode: double, lag = 4, differences = 2
  mode: double, lag = 4, differences = 3
  mode: double, lag = 1, differences = 1
  mode: double, lag = 1, differences = 2
  mode: double, lag = 1, differences = 3
  mode: double, lag = 2, differences = 1
  mode: double, lag = 2, differences = 2
  mode: double, lag = 2, differences = 3
  mode: double, lag = 3, differences = 1
  mode: double, lag = 3, differences = 2
  mode: double, lag = 3, differences = 3
  mode: double, lag = 4, differences = 1
  mode: double, lag = 4, differences = 2
  mode: double, lag = 4, differences = 3
  add_na = TRUE
   num [1:10, 1:8] 67.1 80.1 45.1 8.1 39.1 66.1 27.1 71.1 47.1 46.1 ...
  mode: double, lag = 1, differences = 1
  mode: double, lag = 1, differences = 2
  mode: double, lag = 1, differences = 3
  mode: double, lag = 2, differences = 1
  mode: double, lag = 2, differences = 2
  mode: double, lag = 2, differences = 3
  mode: double, lag = 3, differences = 1
  mode: double, lag = 3, differences = 2
  mode: double, lag = 3, differences = 3
  mode: double, lag = 4, differences = 1
  mode: double, lag = 4, differences = 2
  mode: double, lag = 4, differences = 3
  mode: double, lag = 1, differences = 1
  mode: double, lag = 1, differences = 2
  mode: double, lag = 1, differences = 3
  mode: double, lag = 2, differences = 1
  mode: double, lag = 2, differences = 2
  mode: double, lag = 2, differences = 3
  mode: double, lag = 3, differences = 1
  mode: double, lag = 3, differences = 2
  mode: double, lag = 3, differences = 3
  mode: double, lag = 4, differences = 1
  mode: double, lag = 4, differences = 2
  mode: double, lag = 4, differences = 3
  mode: double, lag = 1, differences = 1
  mode: double, lag = 1, differences = 2
  mode: double, lag = 1, differences = 3
  mode: double, lag = 2, differences = 1
  mode: double, lag = 2, differences = 2
  mode: double, lag = 2, differences = 3
  mode: double, lag = 3, differences = 1
  mode: double, lag = 3, differences = 2
  mode: double, lag = 3, differences = 3
  mode: double, lag = 4, differences = 1
  mode: double, lag = 4, differences = 2
  mode: double, lag = 4, differences = 3
  mode: double, lag = 1, differences = 1
  mode: double, lag = 1, differences = 2
  mode: double, lag = 1, differences = 3
  mode: double, lag = 2, differences = 1
  mode: double, lag = 2, differences = 2
  mode: double, lag = 2, differences = 3
  mode: double, lag = 3, differences = 1
  mode: double, lag = 3, differences = 2
  mode: double, lag = 3, differences = 3
  mode: double, lag = 4, differences = 1
  mode: double, lag = 4, differences = 2
  mode: double, lag = 4, differences = 3
  > 
  > 
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > # All NAs
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > for (mode in c("integer", "double")) {
  +   cat("mode: ", mode, "\n", sep = "")
  +   x <- matrix(NA_real_, nrow = 10L, ncol = 5L)
  +   storage.mode(x) <- mode
  +   str(x)
  +   
  +   dimnames <- list(letters[1:10], LETTERS[1:5])
  +   
  +   # Test with and without dimnames on x
  +   for (setDimnames in c(TRUE, FALSE)) {
  +     if (setDimnames) dimnames(x) <- dimnames
  +     else dimnames(x) <- NULL
  +     # Check dimnames attribute
  +     for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) {
  +       r0 <- rowDiffs_R(x, useNames = useNames)
  +       r1 <- rowDiffs(x, useNames = useNames)
  +       r2 <- t(colDiffs(t(x), useNames = useNames))
  +       stopifnot(all.equal(r1, r0))
  +       stopifnot(all.equal(r2, r0))
  +       stopifnot(all.equal(r1, r2))
  +     } # for (useNames ...)
  +   } # for (setDimnames ...)
  + } # for (mode ...)
  mode: integer
   int [1:10, 1:5] NA NA NA NA NA NA NA NA NA NA ...
  mode: double
   num [1:10, 1:5] NA NA NA NA NA NA NA NA NA NA ...
  > 
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > # A 1x1 matrix
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > x <- matrix(0, nrow = 1L, ncol = 1L)
  > dimnames <- list("a", "A")
  > # Test with and without dimnames on x
  > for (setDimnames in c(TRUE, FALSE)) {
  +   if (setDimnames) dimnames(x) <- dimnames
  +   else dimnames(x) <- NULL
  +   # Check dimnames attribute
  +   for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) {
  +     r0 <- rowDiffs_R(x, useNames = useNames)
  +     r1 <- rowDiffs(x, useNames = useNames)
  +     r2 <- t(colDiffs(t(x), useNames = useNames))
  +     stopifnot(all.equal(r1, r0))
  +     stopifnot(all.equal(r2, r0))
  +     stopifnot(all.equal(r1, r2))
  +   } # for (useNames ...)
  + } # for (setDimnames ...)
  > 
  > proc.time()
     user  system elapsed 
     0.42    0.04    0.45 
Running the tests in 'tests/rowLogSumExps.R' failed.
Complete output:
  > # Test inspired by the harmonic mean example in R-help
  > # thread '[R] Beyond double-precision?' on May 9, 2009.
  > 
  > library("matrixStats")
  > library("stats")
  > 
  > logSumExp0 <- function(lx) {
  +   idx_max <- which.max(lx)
  +   log1p(sum(exp(lx[-idx_max] - lx[idx_max]))) + lx[idx_max]
  + }
  > 
  > n <- 200L
  > set.seed(1)
  > 
  > for (mode in c("integer", "double")) {
  +   cat("mode: ", mode, "\n", sep = "")
  +   x <- matrix(runif(n, min = 1.0, max = 3.0), nrow = 20L)
  +   storage.mode(x) <- mode
  +   str(x)
  + 
  +   # The logarithm of the harmonic mean by rows
  +   y_h <- log(1 / rowMeans(1 / x))
  +   str(y_h)
  + 
  +   lx_neg <- -log(x)
  + 
  +   y0 <- log(ncol(x)) - apply(lx_neg, MARGIN = 1L, FUN = logSumExp0)
  +   stopifnot(all.equal(y0, y_h))
  + 
  +   y1 <- log(ncol(x)) - apply(lx_neg, MARGIN = 1L, FUN = logSumExp)
  +   stopifnot(all.equal(y1, y0))
  + 
  +   y2 <- log(ncol(x)) - rowLogSumExps(lx_neg)
  +   stopifnot(all.equal(y2, y0))
  + 
  +   y3 <- log(ncol(x)) - colLogSumExps(t(lx_neg))
  +   stopifnot(all.equal(y3, y0))
  + 
  + 
  +   # The logarithm of the harmonic mean by columns
  +   y_h <- log(1 / colMeans(1 / x))
  +   str(y_h)
  + 
  +   y0 <- log(nrow(x)) - apply(lx_neg, MARGIN = 2L, FUN = logSumExp0)
  +   stopifnot(all.equal(y0, y_h))
  + 
  +   y1 <- log(nrow(x)) - apply(lx_neg, MARGIN = 2L, FUN = logSumExp)
  +   stopifnot(all.equal(y1, y0))
  + 
  +   y2 <- log(nrow(x)) - colLogSumExps(lx_neg)
  +   stopifnot(all.equal(y2, y0))
  + 
  +   y3 <- log(nrow(x)) - rowLogSumExps(t(lx_neg))
  +   stopifnot(all.equal(y3, y0))
  + 
  +   # Testing names
  +   rownames(lx_neg) <- seq_len(nrow(x))
  +   colnames(lx_neg) <- seq_len(ncol(x))
  +   y2 <- rowLogSumExps(lx_neg, useNames = TRUE)
  +   stopifnot(identical(names(y2), rownames(lx_neg)))
  +   y3 <- colLogSumExps(t(lx_neg), useNames = TRUE)
  +   stopifnot(identical(names(y3), rownames(lx_neg)))
  + } # for (mode ...)
  mode: integer
   int [1:20, 1:10] 1 1 2 2 1 2 2 2 2 1 ...
   num [1:20] 0.357 0.223 0.223 0.288 0.511 ...
   num [1:10] 0.322 0.223 0.322 0.255 0.255 ...
  mode: double
   num [1:20, 1:10] 1.54 1.44 2.03 1.54 1.36 ...
   num [1:20] 0.526 0.466 0.734 0.638 0.604 ...
   num [1:10] 0.627 0.582 0.617 0.474 0.418 ...
  > 
  > 
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > # Corner cases
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > ## Zero-size matrices
  > lx <- matrix(numeric(0L), nrow = 0L, ncol = 0L)
  > y <- rowLogSumExps(lx)
  > print(y)
  numeric(0)
  > stopifnot(length(y) == nrow(lx))
  > 
  > y <- colLogSumExps(lx)
  > print(y)
  numeric(0)
  > stopifnot(length(y) == ncol(lx))
  > 
  > ## Zero-height matrices
  > lx <- matrix(numeric(0L), nrow = 0L, ncol = 5L)
  > y <- rowLogSumExps(lx)
  > print(y)
  numeric(0)
  > stopifnot(length(y) == nrow(lx))
  > 
  > y <- colLogSumExps(lx)
  > print(y)
  [1] -Inf -Inf -Inf -Inf -Inf
  > stopifnot(length(y) == ncol(lx))
  > stopifnot(all(y == -Inf))
  > 
  > ## Zero-width matrices
  > lx <- matrix(numeric(0L), nrow = 5L, ncol = 0L)
  > y <- colLogSumExps(lx)
  > print(y)
  numeric(0)
  > stopifnot(length(y) == ncol(lx))
  > 
  > y <- rowLogSumExps(lx)
  > print(y)
  [1] -Inf -Inf -Inf -Inf -Inf
  > stopifnot(length(y) == nrow(lx))
  > stopifnot(all(y == -Inf))
  > 
  > 
  > ## Matrices with one element
  > lx <- matrix(1.0, nrow = 1L, ncol = 1L)
  > y <- rowLogSumExps(lx)
  > print(y)
  [1] 1
  > stopifnot(length(y) == nrow(lx))
  > stopifnot(all(y == lx))
  > 
  > y <- colLogSumExps(lx)
  > print(y)
  [1] 1
  > stopifnot(length(y) == ncol(lx))
  > stopifnot(all(y == lx))
  > 
  > ## All missing values
  > lx <- matrix(NA_real_, nrow = 1L, ncol = 1L)
  > y <- rowLogSumExps(lx, na.rm = TRUE)
  > print(y)
  [1] -Inf
  > stopifnot(length(y) == nrow(lx))
  > stopifnot(identical(y, -Inf))
  > 
  > lx <- matrix(NA_real_, nrow = 1L, ncol = 1L)
  > y <- colLogSumExps(lx, na.rm = TRUE)
  > print(y)
  [1] -Inf
  > stopifnot(length(y) == ncol(lx))
  > stopifnot(identical(y, -Inf))
  > 
  > lx <- matrix(NA_real_, nrow = 2L, ncol = 2L)
  > y <- rowLogSumExps(lx, na.rm = TRUE)
  > print(y)
  [1] -Inf -Inf
  > stopifnot(length(y) == nrow(lx))
  > stopifnot(all(y == -Inf))
  > 
  > y <- rowLogSumExps(lx, na.rm = FALSE)
  > print(y)
  [1] NA NA
  > stopifnot(length(y) == nrow(lx))
  > stopifnot(all(is.na(y) & !is.nan(y)))
  > 
  > lx <- matrix(NA_real_, nrow = 2L, ncol = 2L)
  > y <- colLogSumExps(lx, na.rm = TRUE)
  > print(y)
  [1] -Inf -Inf
  > stopifnot(length(y) == ncol(lx))
  > stopifnot(all(y == -Inf))
  > 
  > y <- colLogSumExps(lx, na.rm = FALSE)
  > print(y)
  [1] NA NA
  > stopifnot(length(y) == ncol(lx))
  > stopifnot(all(is.na(y) & !is.nan(y)))
  > 
  > ## +Inf values
  > lx <- matrix(c(1, 2, +Inf), nrow = 3L, ncol = 2L)
  > y <- colLogSumExps(lx, na.rm = TRUE)
  > print(y)
  [1] Inf Inf
  > stopifnot(length(y) == ncol(lx))
  > stopifnot(all(y == +Inf))
  > 
  > ## multiple -Inf values
  > lx <- matrix(c(-Inf, -Inf), nrow = 2L, ncol = 3L)
  > y <- rowLogSumExps(lx)
  > print(y)
  [1] -Inf -Inf
  > stopifnot(length(y) == nrow(lx))
  > stopifnot(all(y == -Inf))
  > 
  > lx <- matrix(c(-Inf, 5, -Inf), nrow = 2L, ncol = 3L, byrow = TRUE)
  > y <- rowLogSumExps(lx)
  > print(y)
  [1] 5 5
  > stopifnot(length(y) == nrow(lx))
  > stopifnot(all(y == 5))
  > 
  > ## Bug report #104 (https://github.com/HenrikBengtsson/matrixStats/issues/104)
  > ## (This would core dump on Windows)
  > x <- matrix(0.0, nrow = 2L, ncol = 32762L)
  > y <- colLogSumExps(x)
  > str(y)
   num [1:32762] 0.693 0.693 0.693 0.693 0.693 ...
  > 
  > ## Bug report #120 (https://github.com/HenrikBengtsson/matrixStats/issues/120)
  > ## (This would error if x had rownames/colnames and non-NULL rows/cols were
  > ## used)
  > x <- matrix(runif(6), nrow = 2L, ncol = 3L,
  +             dimnames = list(c("A", "B"), c("a", "b", "c")))
  > y <- colLogSumExps(x, cols = 3:1, useNames = TRUE)
  > stopifnot(names(y) == c("c", "b", "a"))
  > y <- rowLogSumExps(x, rows = 2, useNames = TRUE)
  > stopifnot(names(y) == "B")
  > 
  > 
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > # Check names attributes
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > 
  > ## Create isFALSE() if running on an old version of R
  > if (!exists("isFALSE", mode="function")) {
  +   isFALSE <- function(x) is.logical(x) && length(x) == 1L && !is.na(x) && !x
  + }
  > 
  > rowLogSumExps_R <- function(x, ..., useNames = NA) {
  +   res <- apply(x, MARGIN = 1L, FUN = function(rx, ...) {
  +     log(sum(exp(rx), ...))
  +   }, ...)
  +   if (isFALSE(useNames)) names(res) <- NULL
  +   res
  + }
  > 
  > x <- matrix(runif(6 * 6, min = -6, max = 6), nrow = 6L, ncol = 6L)
  > 
  > # To check names attribute
  > dimnames <- list(letters[1:6], LETTERS[1:6])
  > 
  > # Test with and without dimnames on x
  > for (setDimnames in c(TRUE, FALSE)) {
  +   if (setDimnames) dimnames(x) <- dimnames
  +   else dimnames(x) <- NULL
  +   for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) {
  +     y0 <- rowLogSumExps_R(x, useNames = useNames)
  +     y1 <- rowLogSumExps(x, useNames = useNames)
  +     y2 <- colLogSumExps(t(x), useNames = useNames)
  +     stopifnot(all.equal(y1, y0))
  +     stopifnot(all.equal(y2, y0))
  +   }
  + }
  > 
  > proc.time()
     user  system elapsed 
     0.26    0.09    0.34 
Running the tests in 'tests/rowMads_subset.R' failed.
Complete output:
  > library("matrixStats")
  > 
  > ## Always allow testing of the 'center' argument (as long as it's not defunct)
  > options(matrixStats.center.onUse = "ignore")
  > 
  > rowMads_R <- function(x, na.rm = FALSE, ..., useNames = NA) {
  +   suppressWarnings({
  +     res <- apply(x, MARGIN = 1L, FUN = mad, na.rm = na.rm)
  +   })
  +   if (is.na(useNames) || !useNames) names(res) <- NULL
  +   res
  + }
  > 
  > colMads_R <- function(x, na.rm = FALSE, ..., useNames = NA) {
  +   suppressWarnings({
  +     res <- apply(x, MARGIN = 2L, FUN = mad, na.rm = na.rm)
  +   })
  +   if (is.na(useNames) || !useNames) names(res) <- NULL
  +   res
  + }
  > 
  > rowMads_center <- function(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = NA) {
  +   center <- rowMedians(x, cols = cols, na.rm = na.rm, useNames = FALSE)
  +   rowMads(x, rows = rows, cols = cols, center = center, na.rm = na.rm, useNames = useNames)
  + }
  > 
  > colMads_center <- function(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = NA) {
  +   center <- colMedians(x, rows = rows, na.rm = na.rm, useNames = FALSE)
  +   colMads(x, rows = rows, cols = cols, center = center, na.rm = na.rm, useNames = useNames)
  + }
  > 
  > 
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > # Subsetted tests
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > source("utils/validateIndicesFramework.R")
  > x <- matrix(runif(6 * 6, min = -6, max = 6), nrow = 6, ncol = 6)
  > storage.mode(x) <- "integer"
  > 
  > # To check names attribute
  > dimnames <- list(letters[1:6], LETTERS[1:6])
  > 
  > # Test with and without dimnames on x
  > for (setDimnames in c(TRUE, FALSE)) {
  +   if (setDimnames) dimnames(x) <- dimnames
  +   else dimnames(x) <- NULL
  + 
  +   count <- 0L
  +   for (rows in index_cases) {
  +     for (cols in index_cases) {
  +       count <- count + 1L
  +       na.rm <- c(TRUE, FALSE)[count %% 2 + 1]
  +       useNames <- c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)
  +       useNames <- useNames[count %% length(useNames) + 1]
  +       
  +       validateIndicesTestMatrix(x, rows, cols,
  +                                 ftest = rowMads, fsure = rowMads_R,
  +                                 na.rm = na.rm, useNames = useNames)
  +       validateIndicesTestMatrix(x, rows, cols,
  +                                 ftest = rowMads_center, fsure = rowMads_R,
  +                                 na.rm = na.rm, useNames = useNames)
  + 
  +       validateIndicesTestMatrix(x, rows, cols,
  +                                 fcoltest = colMads, fsure = rowMads_R,
  +                                 na.rm = na.rm, useNames = useNames)
  +       validateIndicesTestMatrix(x, rows, cols,
  +                                 fcoltest = colMads_center, fsure = rowMads_R,
  +                                 na.rm = na.rm, useNames = useNames)
  +     }
  +   }
  + }
  > 
  > proc.time()
     user  system elapsed 
     1.62    0.12    1.89 
Running the tests in 'tests/rowOrderStats.R' failed.
Complete output:
  > library("matrixStats")
  > library("stats")
  > 
  > asWhich <- function(probs, max) {
  +   idx <- as.integer(round(probs * max))
  +   if (idx < 1L) {
  +     idx <- 1L
  +   } else if (idx > max) {
  +     idx <- max
  +   }
  +   idx
  + } # asWhich()
  > 
  > rowOrderStats_R <- function(x, probs, ..., useNames = NA) {
  +   ans <- apply(x, MARGIN = 1L, FUN = quantile, probs = probs, type = 3L)
  +   
  +   # Remove Attributes
  +   if (is.na(useNames) || !useNames || length(ans) == 0L) attributes(ans) <- NULL
  +   ans
  + } # rowOrderStats_R()
  > 
  > 
  > set.seed(1)
  > 
  > 
  > # Simulate data in a matrix of any shape
  > nrow <- 60L
  > ncol <- 30L
  > x <- rnorm(nrow * ncol)
  > dim(x) <- c(nrow, ncol)
  > probs <- 0.3
  > which <- asWhich(probs, max = ncol)
  > 
  > y0 <- rowOrderStats_R(x, probs = probs)
  > y1 <- rowOrderStats(x, which = which)
  > stopifnot(all.equal(y1, y0))
  > y2 <- colOrderStats(t(x), which = which)
  > stopifnot(all.equal(y2, y0))
  > 
  > 
  > 
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > # Consistency checks
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > for (mode in c("integer", "double")) {
  +   cat("Consistency checks without NAs:\n")
  +   for (kk in 1:3) {
  +     cat("Random test #", kk, "\n", sep = "")
  + 
  +     # Simulate data in a matrix of any shape
  +     nrow <- sample(20L, size = 1L)
  +     ncol <- sample(20L, size = 1L)
  +     x <- rnorm(nrow * ncol)
  +     dim(x) <- c(nrow, ncol)
  + 
  +     cat("mode: ", mode, "\n", sep = "")
  +     storage.mode(x) <- mode
  +     str(x)
  + 
  +     probs <- runif(1)
  +     which <- asWhich(probs, max = ncol)
  + 
  +     y0 <- rowOrderStats_R(x, probs = probs)
  +     y1 <- rowOrderStats(x, which = which)
  +     stopifnot(all.equal(y1, y0))
  +     y2 <- colOrderStats(t(x), which = which)
  +     stopifnot(all.equal(y2, y0))
  +   } # for (kk in ...)
  + } # for (mode ...)
  Consistency checks without NAs:
  Random test #1
  mode: integer
   int [1:14, 1:6] 0 0 1 0 2 -1 1 0 0 0 ...
  Random test #2
  mode: integer
   int [1:8, 1:13] 0 0 1 -2 0 0 0 0 1 0 ...
  Random test #3
  mode: integer
   int [1:20, 1:17] 0 0 0 0 1 0 1 0 0 -1 ...
  Consistency checks without NAs:
  Random test #1
  mode: double
   num [1:9, 1:5] -1.4286 -0.00386 -0.70456 -0.29242 -0.49607 ...
  Random test #2
  mode: double
   num [1:11, 1:20] -0.796 0.482 -0.952 0.5 1.242 ...
  Random test #3
  mode: double
   num [1:7, 1:18] 1.553 -2.405 0.167 -0.403 -1.746 ...
  > 
  > 
  > # Check names attribute
  > x <- matrix(1:9 + 0.1, nrow = 3L, ncol = 3L)
  > 
  > probs <- runif(1)
  > which <- asWhich(probs, max = ncol(x))
  > 
  > dimnames <- list(letters[1:3], LETTERS[1:3])
  > 
  > # Test with and without dimnames on x
  > for (setDimnames in c(TRUE, FALSE)) {
  +   if (setDimnames) dimnames(x) <- dimnames
  +   else dimnames(x) <- NULL
  +   # Check names attribute
  +   for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) {
  +     y0 <- rowOrderStats_R(x, probs = probs, useNames = useNames)
  +     y1 <- rowOrderStats(x, which = which, useNames = useNames)
  +     stopifnot(all.equal(y1, y0))
  +     y2 <- colOrderStats(t(x), which = which, useNames = useNames)
  +     stopifnot(all.equal(y2, y0))    
  +   }
  + }
  > 
  > proc.time()
     user  system elapsed 
     0.28    0.09    0.34 
Running the tests in 'tests/rowProds_subset.R' failed.
Complete output:
  > library("matrixStats")
  > 
  > rowProds_R <- function(x, FUN = prod, na.rm = FALSE, ..., useNames = NA) {
  +   res <- apply(x, MARGIN = 1L, FUN = FUN, na.rm = na.rm)
  +   if (is.na(useNames) || !useNames) names(res) <- NULL
  +   res
  + }
  > 
  > 
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > # Subsetted tests
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > source("utils/validateIndicesFramework.R")
  > x <- matrix(runif(6 * 6, min = -6, max = 6), nrow = 6, ncol = 6)
  > storage.mode(x) <- "integer"
  > 
  > # To check names attribute
  > dimnames <- list(letters[1:6], LETTERS[1:6])
  > 
  > # Test with and without dimnames on x
  > for (setDimnames in c(TRUE, FALSE)) {
  +   if (setDimnames) dimnames(x) <- dimnames
  +   else dimnames(x) <- NULL
  +   for (rows in index_cases) {
  +     for (cols in index_cases) {
  +       for (na.rm in c(TRUE, FALSE)) {
  +         for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) {
  +           validateIndicesTestMatrix(x, rows, cols,
  +                                     ftest = rowProds, fsure = rowProds_R,
  +                                     method = "expSumLog",
  +                                     FUN = product, na.rm = na.rm, useNames = useNames)
  +           validateIndicesTestMatrix(x, rows, cols,
  +                                     fcoltest = colProds, fsure = rowProds_R,
  +                                     method = "expSumLog",
  +                                     FUN = product, na.rm = na.rm, useNames = useNames)
  +         }
  +       }
  +     }
  +   }
  + }
  > 
  > proc.time()
     user  system elapsed 
     1.67    0.17    1.78 
Running the tests in 'tests/rowQuantiles.R' failed.
Complete output:
  > library("matrixStats")
  > 
  > ## Create isFALSE() if running on an old version of R
  > if (!exists("isFALSE", mode="function")) {
  +   isFALSE <- function(x) is.logical(x) && length(x) == 1L && !is.na(x) && !x
  + }
  > 
  > rowQuantiles_R <- function(x, probs = c(0, 0.25, 0.50, 0.75, 1), na.rm = FALSE, drop = TRUE, type = 7L, ..., useNames = NA) {
  +   q <- apply(x, MARGIN = 1L, FUN = function(x, probs, na.rm) {
  +     if (!na.rm && any(is.na(x))) {
  +       na_value <- NA_real_
  +       if (type != 7L) storage.mode(na_value) <- storage.mode(x)
  +       rep(na_value, times = length(probs))
  +     } else {
  +       as.vector(quantile(x, probs = probs, na.rm = na.rm, type = type, names = FALSE, ...))
  +     }
  +   }, probs = probs, na.rm = na.rm)
  + 
  +   if (!is.null(dim(q))) q <- t(q)
  +   else dim(q) <- c(nrow(x), length(probs))
  + 
  +   colnames(q) <- matrixStats:::quantile_probs_names(probs)
  +   rownames(q) <- rownames(x)
  +   if (isFALSE(useNames)) dimnames(q) <- NULL
  + 
  +   if (drop) q <- drop(q)
  +   q
  + }
  > 
  > 
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > # Test with multiple quantiles
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > for (mode in c("logical", "integer", "double")) {
  +   cat("mode: ", mode, "\n", sep = "")
  +   x <- matrix(1:40 + 0.1, nrow = 8, ncol = 5)
  +   storage.mode(x) <- mode
  +   dimnames <- lapply(dim(x), FUN = function(n) letters[seq_len(n)])
  +   str(x)
  + 
  +   probs <- c(0, 0.5, 1)
  +   # Test with and without dimnames on x
  +   for (setDimnames in c(TRUE, FALSE)) {
  +     if (setDimnames) dimnames(x) <- dimnames
  +     else dimnames(x) <- NULL    
  +     # Check names attribute
  +     for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) {
  +       q0 <- rowQuantiles_R(x, probs = probs, useNames = useNames)
  +       print(q0)
  +       q1 <- rowQuantiles(x, probs = probs, useNames = useNames)
  +       print(q1)
  +       ## FIXME: Workaround for R (< 3.0.0)
  +       if (getRversion() < "3.0.0" && mode == "logical") storage.mode(q1) <- storage.mode(q0)
  +       stopifnot(all.equal(q1, q0))
  +       q2 <- colQuantiles(t(x), probs = probs, useNames = useNames)
  +       ## FIXME: Workaround for R (< 3.0.0)
  +       if (getRversion() < "3.0.0" && mode == "logical") storage.mode(q2) <- storage.mode(q0)
  +       stopifnot(all.equal(q2, q0))      
  +     }
  +   }
  + } # for (mode ...)
  mode: logical
   logi [1:8, 1:5] TRUE TRUE TRUE TRUE TRUE TRUE ...
    0% 50% 100%
  a  1   1    1
  b  1   1    1
  c  1   1    1
  d  1   1    1
  e  1   1    1
  f  1   1    1
  g  1   1    1
  h  1   1    1
    0% 50% 100%
  a  1   1    1
  b  1   1    1
  c  1   1    1
  d  1   1    1
  e  1   1    1
  f  1   1    1
  g  1   1    1
  h  1   1    1
       [,1] [,2] [,3]
  [1,]    1    1    1
  [2,]    1    1    1
  [3,]    1    1    1
  [4,]    1    1    1
  [5,]    1    1    1
  [6,]    1    1    1
  [7,]    1    1    1
  [8,]    1    1    1
       [,1] [,2] [,3]
  [1,]    1    1    1
  [2,]    1    1    1
  [3,]    1    1    1
  [4,]    1    1    1
  [5,]    1    1    1
  [6,]    1    1    1
  [7,]    1    1    1
  [8,]    1    1    1
       0% 50% 100%
  [1,]  1   1    1
  [2,]  1   1    1
  [3,]  1   1    1
  [4,]  1   1    1
  [5,]  1   1    1
  [6,]  1   1    1
  [7,]  1   1    1
  [8,]  1   1    1
       0% 50% 100%
  [1,]  1   1    1
  [2,]  1   1    1
  [3,]  1   1    1
  [4,]  1   1    1
  [5,]  1   1    1
  [6,]  1   1    1
  [7,]  1   1    1
  [8,]  1   1    1
       [,1] [,2] [,3]
  [1,]    1    1    1
  [2,]    1    1    1
  [3,]    1    1    1
  [4,]    1    1    1
  [5,]    1    1    1
  [6,]    1    1    1
  [7,]    1    1    1
  [8,]    1    1    1
       [,1] [,2] [,3]
  [1,]    1    1    1
  [2,]    1    1    1
  [3,]    1    1    1
  [4,]    1    1    1
  [5,]    1    1    1
  [6,]    1    1    1
  [7,]    1    1    1
  [8,]    1    1    1
  mode: integer
   int [1:8, 1:5] 1 2 3 4 5 6 7 8 9 10 ...
    0% 50% 100%
  a  1  17   33
  b  2  18   34
  c  3  19   35
  d  4  20   36
  e  5  21   37
  f  6  22   38
  g  7  23   39
  h  8  24   40
    0% 50% 100%
  a  1  17   33
  b  2  18   34
  c  3  19   35
  d  4  20   36
  e  5  21   37
  f  6  22   38
  g  7  23   39
  h  8  24   40
       [,1] [,2] [,3]
  [1,]    1   17   33
  [2,]    2   18   34
  [3,]    3   19   35
  [4,]    4   20   36
  [5,]    5   21   37
  [6,]    6   22   38
  [7,]    7   23   39
  [8,]    8   24   40
       [,1] [,2] [,3]
  [1,]    1   17   33
  [2,]    2   18   34
  [3,]    3   19   35
  [4,]    4   20   36
  [5,]    5   21   37
  [6,]    6   22   38
  [7,]    7   23   39
  [8,]    8   24   40
       0% 50% 100%
  [1,]  1  17   33
  [2,]  2  18   34
  [3,]  3  19   35
  [4,]  4  20   36
  [5,]  5  21   37
  [6,]  6  22   38
  [7,]  7  23   39
  [8,]  8  24   40
       0% 50% 100%
  [1,]  1  17   33
  [2,]  2  18   34
  [3,]  3  19   35
  [4,]  4  20   36
  [5,]  5  21   37
  [6,]  6  22   38
  [7,]  7  23   39
  [8,]  8  24   40
       [,1] [,2] [,3]
  [1,]    1   17   33
  [2,]    2   18   34
  [3,]    3   19   35
  [4,]    4   20   36
  [5,]    5   21   37
  [6,]    6   22   38
  [7,]    7   23   39
  [8,]    8   24   40
       [,1] [,2] [,3]
  [1,]    1   17   33
  [2,]    2   18   34
  [3,]    3   19   35
  [4,]    4   20   36
  [5,]    5   21   37
  [6,]    6   22   38
  [7,]    7   23   39
  [8,]    8   24   40
  mode: double
   num [1:8, 1:5] 1.1 2.1 3.1 4.1 5.1 6.1 7.1 8.1 9.1 10.1 ...
     0%  50% 100%
  a 1.1 17.1 33.1
  b 2.1 18.1 34.1
  c 3.1 19.1 35.1
  d 4.1 20.1 36.1
  e 5.1 21.1 37.1
  f 6.1 22.1 38.1
  g 7.1 23.1 39.1
  h 8.1 24.1 40.1
     0%  50% 100%
  a 1.1 17.1 33.1
  b 2.1 18.1 34.1
  c 3.1 19.1 35.1
  d 4.1 20.1 36.1
  e 5.1 21.1 37.1
  f 6.1 22.1 38.1
  g 7.1 23.1 39.1
  h 8.1 24.1 40.1
       [,1] [,2] [,3]
  [1,]  1.1 17.1 33.1
  [2,]  2.1 18.1 34.1
  [3,]  3.1 19.1 35.1
  [4,]  4.1 20.1 36.1
  [5,]  5.1 21.1 37.1
  [6,]  6.1 22.1 38.1
  [7,]  7.1 23.1 39.1
  [8,]  8.1 24.1 40.1
       [,1] [,2] [,3]
  [1,]  1.1 17.1 33.1
  [2,]  2.1 18.1 34.1
  [3,]  3.1 19.1 35.1
  [4,]  4.1 20.1 36.1
  [5,]  5.1 21.1 37.1
  [6,]  6.1 22.1 38.1
  [7,]  7.1 23.1 39.1
  [8,]  8.1 24.1 40.1
        0%  50% 100%
  [1,] 1.1 17.1 33.1
  [2,] 2.1 18.1 34.1
  [3,] 3.1 19.1 35.1
  [4,] 4.1 20.1 36.1
  [5,] 5.1 21.1 37.1
  [6,] 6.1 22.1 38.1
  [7,] 7.1 23.1 39.1
  [8,] 8.1 24.1 40.1
        0%  50% 100%
  [1,] 1.1 17.1 33.1
  [2,] 2.1 18.1 34.1
  [3,] 3.1 19.1 35.1
  [4,] 4.1 20.1 36.1
  [5,] 5.1 21.1 37.1
  [6,] 6.1 22.1 38.1
  [7,] 7.1 23.1 39.1
  [8,] 8.1 24.1 40.1
       [,1] [,2] [,3]
  [1,]  1.1 17.1 33.1
  [2,]  2.1 18.1 34.1
  [3,]  3.1 19.1 35.1
  [4,]  4.1 20.1 36.1
  [5,]  5.1 21.1 37.1
  [6,]  6.1 22.1 38.1
  [7,]  7.1 23.1 39.1
  [8,]  8.1 24.1 40.1
       [,1] [,2] [,3]
  [1,]  1.1 17.1 33.1
  [2,]  2.1 18.1 34.1
  [3,]  3.1 19.1 35.1
  [4,]  4.1 20.1 36.1
  [5,]  5.1 21.1 37.1
  [6,]  6.1 22.1 38.1
  [7,]  7.1 23.1 39.1
  [8,]  8.1 24.1 40.1
  > 
  > 
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > # Test with a single quantile
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > for (mode in c("logical", "integer", "double")) {
  +   cat("mode: ", mode, "\n", sep = "")
  +   x <- matrix(1:40, nrow = 8, ncol = 5)
  +   storage.mode(x) <- mode
  +   dimnames <- lapply(dim(x), FUN = function(n) letters[seq_len(n)])
  +   str(x)
  + 
  +   probs <- c(0.5)
  +   # Test with and without dimnames on x
  +   for (setDimnames in c(TRUE, FALSE)) {
  +     if (setDimnames) dimnames(x) <- dimnames
  +     else dimnames(x) <- NULL    
  +     # Check names attribute
  +     for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) {
  +       q0 <- rowQuantiles_R(x, probs = probs, useNames = useNames)
  +       print(q0)
  +       q1 <- rowQuantiles(x, probs = probs, useNames = useNames)
  +       ## FIXME: Workaround for R (< 3.0.0)
  +       if (getRversion() < "3.0.0" && mode == "logical") storage.mode(q1) <- storage.mode(q0)
  +       print(q1)
  +       stopifnot(all.equal(q1, q0))
  +       q2 <- colQuantiles(t(x), probs = probs, useNames = useNames)
  +       ## FIXME: Workaround for R (< 3.0.0)
  +       if (getRversion() < "3.0.0" && mode == "logical") storage.mode(q2) <- storage.mode(q0)
  +       stopifnot(all.equal(q2, q0))      
  +     }
  +   }
  + } # for (mode ...)
  mode: logical
   logi [1:8, 1:5] TRUE TRUE TRUE TRUE TRUE TRUE ...
  a b c d e f g h 
  1 1 1 1 1 1 1 1 
  a b c d e f g h 
  1 1 1 1 1 1 1 1 
  [1] 1 1 1 1 1 1 1 1
  [1] 1 1 1 1 1 1 1 1
  [1] 1 1 1 1 1 1 1 1
  [1] 1 1 1 1 1 1 1 1
  [1] 1 1 1 1 1 1 1 1
  [1] 1 1 1 1 1 1 1 1
  mode: integer
   int [1:8, 1:5] 1 2 3 4 5 6 7 8 9 10 ...
   a  b  c  d  e  f  g  h 
  17 18 19 20 21 22 23 24 
   a  b  c  d  e  f  g  h 
  17 18 19 20 21 22 23 24 
  [1] 17 18 19 20 21 22 23 24
  [1] 17 18 19 20 21 22 23 24
  [1] 17 18 19 20 21 22 23 24
  [1] 17 18 19 20 21 22 23 24
  [1] 17 18 19 20 21 22 23 24
  [1] 17 18 19 20 21 22 23 24
  mode: double
   num [1:8, 1:5] 1 2 3 4 5 6 7 8 9 10 ...
   a  b  c  d  e  f  g  h 
  17 18 19 20 21 22 23 24 
   a  b  c  d  e  f  g  h 
  17 18 19 20 21 22 23 24 
  [1] 17 18 19 20 21 22 23 24
  [1] 17 18 19 20 21 22 23 24
  [1] 17 18 19 20 21 22 23 24
  [1] 17 18 19 20 21 22 23 24
  [1] 17 18 19 20 21 22 23 24
  [1] 17 18 19 20 21 22 23 24
  > 
  > 
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > # Consistency checks
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > set.seed(1)
  > 
  > probs <- seq(from = 0, to = 1, by = 0.25)
  > 
  > cat("Consistency checks:\n")
  Consistency checks:
  > n_sims <- if (Sys.getenv("_R_CHECK_USE_VALGRIND_") != "") 6L else 24L
  > for (kk in seq_len(n_sims)) {
  +   cat("Random test #", kk, "\n", sep = "")
  + 
  +   # Simulate data in a matrix of any shape
  +   dim <- sample(20:60, size = 2L)
  +   n <- prod(dim)
  +   x <- rnorm(n, sd = 100)
  +   dim(x) <- dim
  +   dimnames <- lapply(dim(x), FUN = function(n) rep(letters, length.out = n))
  + 
  +   # Add NAs?
  +   has_na <- ((kk %% 2) == 0L)
  +   if (has_na) {
  +     cat("Adding NAs\n")
  +     nna <- sample(n, size = 1)
  +     na_values <- c(NA_real_, NaN)
  +     t <- sample(na_values, size = nna, replace = TRUE)
  +     x[sample(length(x), size = nna)] <- t
  +   }
  + 
  +   # Logical, integer, or double?
  +   mode <- "numeric"
  +   if ((kk %% 6) %in% 1:2) {
  +     cat("Coercing to logical\n")
  +     mode <- "logical"
  +   } else if ((kk %% 6) %in% 3:4) {
  +     cat("Coercing to integers\n")
  +     mode <- "integer"
  +   }
  +   storage.mode(x) <- mode
  +   
  +   str(x)
  + 
  +   # rowQuantiles():
  +   for (type in 1:9) {
  +     cat(sprintf("type=%d, has_na=%s:\n", type, has_na))
  +     # Test with and without dimnames on x
  +     for (setDimnames in c(TRUE, FALSE)) {
  +       if (setDimnames) dimnames(x) <- dimnames
  +       else dimnames(x) <- NULL    
  +       # Check names attribute
  +       for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) {
  +         q0 <- rowQuantiles_R(x, probs = probs, na.rm = has_na, type = type, useNames = useNames)
  +         q1 <- rowQuantiles(x, probs = probs, na.rm = has_na, type = type, useNames = useNames)
  +         ## FIXME: Workaround for R (< 3.0.0)
  +         if (getRversion() < "3.0.0" && mode == "logical" && !has_na && type == 7L) storage.mode(q1) <- storage.mode(q0)
  +         stopifnot(all.equal(q1, q0))
  +         q2 <- colQuantiles(t(x), probs = probs, na.rm = has_na, type = type, useNames = useNames)
  +         ## FIXME: Workaround for R (< 3.0.0)
  +         if (getRversion() < "3.0.0" && mode == "logical" && !has_na && type == 7L) storage.mode(q2) <- storage.mode(q0)
  +         stopifnot(all.equal(q2, q0))
  +       }
  +     }
  +   }
  + } # for (kk ...)
  Random test #1
  Coercing to logical
   logi [1:23, 1:58] TRUE TRUE TRUE TRUE TRUE TRUE ...
  type=1, has_na=FALSE:
  type=2, has_na=FALSE:
  type=3, has_na=FALSE:
  type=4, has_na=FALSE:
  type=5, has_na=FALSE:
  type=6, has_na=FALSE:
  type=7, has_na=FALSE:
  type=8, has_na=FALSE:
  type=9, has_na=FALSE:
  Random test #2
  Adding NAs
  Coercing to logical
   logi [1:58, 1:33] TRUE TRUE TRUE TRUE TRUE NA ...
  type=1, has_na=TRUE:
  type=2, has_na=TRUE:
  type=3, has_na=TRUE:
  type=4, has_na=TRUE:
  type=5, has_na=TRUE:
  type=6, has_na=TRUE:
  type=7, has_na=TRUE:
  type=8, has_na=TRUE:
  type=9, has_na=TRUE:
  Random test #3
  Coercing to integers
   int [1:28, 1:60] 119 -164 115 -129 209 -175 2 -32 120 -28 ...
  type=1, has_na=FALSE:
  type=2, has_na=FALSE:
  type=3, has_na=FALSE:
  type=4, has_na=FALSE:
  type=5, has_na=FALSE:
  type=6, has_na=FALSE:
  type=7, has_na=FALSE:
  type=8, has_na=FALSE:
  type=9, has_na=FALSE:
  Random test #4
  Adding NAs
  Coercing to integers
   int [1:54, 1:35] 147 11 116 -50 NA -69 132 NA 114 NA ...
  type=1, has_na=TRUE:
  type=2, has_na=TRUE:
  type=3, has_na=TRUE:
  type=4, has_na=TRUE:
  type=5, has_na=TRUE:
  type=6, has_na=TRUE:
  type=7, has_na=TRUE:
  type=8, has_na=TRUE:
  type=9, has_na=TRUE:
  Random test #5
   num [1:39, 1:53] 5.94 -27.16 -30.78 173 126.05 ...
  type=1, has_na=FALSE:
  type=2, has_na=FALSE:
  type=3, has_na=FALSE:
  type=4, has_na=FALSE:
  type=5, has_na=FALSE:
  type=6, has_na=FALSE:
  type=7, has_na=FALSE:
  type=8, has_na=FALSE:
  type=9, has_na=FALSE:
  Random test #6
  Adding NAs
   num [1:46, 1:22] 197 -107 15 148 -110 ...
  type=1, has_na=TRUE:
  type=2, has_na=TRUE:
  type=3, has_na=TRUE:
  type=4, has_na=TRUE:
  type=5, has_na=TRUE:
  type=6, has_na=TRUE:
  type=7, has_na=TRUE:
  type=8, has_na=TRUE:
  type=9, has_na=TRUE:
  Random test #7
  Coercing to logical
   logi [1:21, 1:51] TRUE TRUE TRUE TRUE TRUE TRUE ...
  type=1, has_na=FALSE:
  type=2, has_na=FALSE:
  type=3, has_na=FALSE:
  type=4, has_na=FALSE:
  type=5, has_na=FALSE:
  type=6, has_na=FALSE:
  type=7, has_na=FALSE:
  type=8, has_na=FALSE:
  type=9, has_na=FALSE:
  Random test #8
  Adding NAs
  Coercing to logical
   logi [1:33, 1:53] NA NA TRUE TRUE TRUE TRUE ...
  type=1, has_na=TRUE:
  type=2, has_na=TRUE:
  type=3, has_na=TRUE:
  type=4, has_na=TRUE:
  type=5, has_na=TRUE:
  type=6, has_na=TRUE:
  type=7, has_na=TRUE:
  type=8, has_na=TRUE:
  type=9, has_na=TRUE:
  Random test #9
  Coercing to integers
   int [1:53, 1:24] -73 10 -73 -5 44 -107 -100 95 58 -50 ...
  type=1, has_na=FALSE:
  type=2, has_na=FALSE:
  type=3, has_na=FALSE:
  type=4, has_na=FALSE:
  type=5, has_na=FALSE:
  type=6, has_na=FALSE:
  type=7, has_na=FALSE:
  type=8, has_na=FALSE:
  type=9, has_na=FALSE:
  Random test #10
  Adding NAs
  Coercing to integers
   int [1:44, 1:20] NA -140 NA -57 -252 NA NA 20 NA NA ...
  type=1, has_na=TRUE:
  type=2, has_na=TRUE:
  type=3, has_na=TRUE:
  type=4, has_na=TRUE:
  type=5, has_na=TRUE:
  type=6, has_na=TRUE:
  type=7, has_na=TRUE:
  type=8, has_na=TRUE:
  type=9, has_na=TRUE:
  Random test #11
   num [1:54, 1:23] -160.87 74.13 196.08 7.27 4.92 ...
  type=1, has_na=FALSE:
  type=2, has_na=FALSE:
  type=3, has_na=FALSE:
  type=4, has_na=FALSE:
  type=5, has_na=FALSE:
  type=6, has_na=FALSE:
  type=7, has_na=FALSE:
  type=8, has_na=FALSE:
  type=9, has_na=FALSE:
  Random test #12
  Adding NAs
   num [1:59, 1:27] -139.2 -86.3 NA -40.7 NA ...
  type=1, has_na=TRUE:
  type=2, has_na=TRUE:
  type=3, has_na=TRUE:
  type=4, has_na=TRUE:
  type=5, has_na=TRUE:
  type=6, has_na=TRUE:
  type=7, has_na=TRUE:
  type=8, has_na=TRUE:
  type=9, has_na=TRUE:
  Random test #13
  Coercing to logical
   logi [1:53, 1:60] TRUE TRUE TRUE TRUE TRUE TRUE ...
  type=1, has_na=FALSE:
  type=2, has_na=FALSE:
  type=3, has_na=FALSE:
  type=4, has_na=FALSE:
  type=5, has_na=FALSE:
  type=6, has_na=FALSE:
  type=7, has_na=FALSE:
  type=8, has_na=FALSE:
  type=9, has_na=FALSE:
  Random test #14
  Adding NAs
  Coercing to logical
   logi [1:22, 1:57] TRUE TRUE TRUE TRUE TRUE TRUE ...
  type=1, has_na=TRUE:
  type=2, has_na=TRUE:
  type=3, has_na=TRUE:
  type=4, has_na=TRUE:
  type=5, has_na=TRUE:
  type=6, has_na=TRUE:
  type=7, has_na=TRUE:
  type=8, has_na=TRUE:
  type=9, has_na=TRUE:
  Random test #15
  Coercing to integers
   int [1:20, 1:34] 78 -41 183 190 -71 37 0 -4 -86 27 ...
  type=1, has_na=FALSE:
  type=2, has_na=FALSE:
  type=3, has_na=FALSE:
  type=4, has_na=FALSE:
  type=5, has_na=FALSE:
  type=6, has_na=FALSE:
  type=7, has_na=FALSE:
  type=8, has_na=FALSE:
  type=9, has_na=FALSE:
  Random test #16
  Adding NAs
  Coercing to integers
   int [1:42, 1:37] NA 12 -15 41 -28 17 NA -74 NA NA ...
  type=1, has_na=TRUE:
  type=2, has_na=TRUE:
  type=3, has_na=TRUE:
  type=4, has_na=TRUE:
  type=5, has_na=TRUE:
  type=6, has_na=TRUE:
  type=7, has_na=TRUE:
  type=8, has_na=TRUE:
  type=9, has_na=TRUE:
  Random test #17
   num [1:42, 1:29] -50.51 -6.51 -117.59 135.58 226.87 ...
  type=1, has_na=FALSE:
  type=2, has_na=FALSE:
  type=3, has_na=FALSE:
  type=4, has_na=FALSE:
  type=5, has_na=FALSE:
  type=6, has_na=FALSE:
  type=7, has_na=FALSE:
  type=8, has_na=FALSE:
  type=9, has_na=FALSE:
  Random test #18
  Adding NAs
   num [1:57, 1:39] 223 156.8 -44.6 -127.5 -147.7 ...
  type=1, has_na=TRUE:
  type=2, has_na=TRUE:
  type=3, has_na=TRUE:
  type=4, has_na=TRUE:
  type=5, has_na=TRUE:
  type=6, has_na=TRUE:
  type=7, has_na=TRUE:
  type=8, has_na=TRUE:
  type=9, has_na=TRUE:
  Random test #19
  Coercing to logical
   logi [1:52, 1:57] TRUE TRUE TRUE TRUE TRUE TRUE ...
  type=1, has_na=FALSE:
  type=2, has_na=FALSE:
  type=3, has_na=FALSE:
  type=4, has_na=FALSE:
  type=5, has_na=FALSE:
  type=6, has_na=FALSE:
  type=7, has_na=FALSE:
  type=8, has_na=FALSE:
  type=9, has_na=FALSE:
  Random test #20
  Adding NAs
  Coercing to logical
   logi [1:25, 1:48] NA TRUE NA NA NA NA ...
  type=1, has_na=TRUE:
  type=2, has_na=TRUE:
  type=3, has_na=TRUE:
  type=4, has_na=TRUE:
  type=5, has_na=TRUE:
  type=6, has_na=TRUE:
  type=7, has_na=TRUE:
  type=8, has_na=TRUE:
  type=9, has_na=TRUE:
  Random test #21
  Coercing to integers
   int [1:53, 1:27] 3 -30 203 -49 19 -45 -138 28 46 -44 ...
  type=1, has_na=FALSE:
  type=2, has_na=FALSE:
  type=3, has_na=FALSE:
  type=4, has_na=FALSE:
  type=5, has_na=FALSE:
  type=6, has_na=FALSE:
  type=7, has_na=FALSE:
  type=8, has_na=FALSE:
  type=9, has_na=FALSE:
  Random test #22
  Adding NAs
  Coercing to integers
   int [1:48, 1:36] -131 NA NA -201 45 -17 NA 57 NA NA ...
  type=1, has_na=TRUE:
  type=2, has_na=TRUE:
  type=3, has_na=TRUE:
  type=4, has_na=TRUE:
  type=5, has_na=TRUE:
  type=6, has_na=TRUE:
  type=7, has_na=TRUE:
  type=8, has_na=TRUE:
  type=9, has_na=TRUE:
  Random test #23
   num [1:23, 1:43] -99.2 -68.8 -86.7 -104.2 48 ...
  type=1, has_na=FALSE:
  type=2, has_na=FALSE:
  type=3, has_na=FALSE:
  type=4, has_na=FALSE:
  type=5, has_na=FALSE:
  type=6, has_na=FALSE:
  type=7, has_na=FALSE:
  type=8, has_na=FALSE:
  type=9, has_na=FALSE:
  Random test #24
  Adding NAs
   num [1:53, 1:29] NaN -67.6 10.8 -88.4 130.1 ...
  type=1, has_na=TRUE:
  type=2, has_na=TRUE:
  type=3, has_na=TRUE:
  type=4, has_na=TRUE:
  type=5, has_na=TRUE:
  type=6, has_na=TRUE:
  type=7, has_na=TRUE:
  type=8, has_na=TRUE:
  type=9, has_na=TRUE:
  > 
  > 
  > 
  > for (mode in c("logical", "integer", "double")) {
  +   naValue <- NA_real_
  +   storage.mode(naValue) <- mode
  + 
  +   someValue <- 1
  +   storage.mode(someValue) <- mode
  + 
  +   for (type in 1:9) {
  +     # - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  +     # All NA
  +     # - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  +     x <- matrix(naValue, nrow = 3L, ncol = 4L)
  +     dimnames <- lapply(dim(x), FUN = function(n) letters[seq_len(n)])
  +     # Test with and without dimnames on x
  +     for (setDimnames in c(TRUE, FALSE)) {
  +       if (setDimnames) dimnames(x) <- dimnames
  +       else dimnames(x) <- NULL    
  +       # Check names attribute
  +       for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) {
  +         qr0 <- rowQuantiles_R(x, type = type, useNames = useNames)
  +         
  +         qr <- rowQuantiles(x, type = type, useNames = useNames)
  +         stopifnot(identical(qr, qr0))
  +         
  +         # x <- matrix(naValue, nrow = 4L, ncol = 3L)
  +         qc <- colQuantiles(t(x), type = type, useNames = useNames)
  +         
  +         stopifnot(identical(qc, qr))
  +       }
  +     }
  + 
  + 
  +     # - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  +     # Empty matrices
  +     # - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  +     probs <- c(0, 0.25, 0.75, 1)
  +     x <- matrix(naValue, nrow = 0L, ncol = 0L)
  +     dimnames(x) <- lapply(dim(x), FUN = function(n) letters[seq_len(n)])
  +     q <- rowQuantiles(x, probs = probs, type = type, useNames = TRUE)
  +     stopifnot(identical(dim(q), c(nrow(x), length(probs))))
  +     q <- colQuantiles(x, probs = probs, type = type, useNames = TRUE)
  +     stopifnot(identical(dim(q), c(ncol(x), length(probs))))
  +     
  +     x <- matrix(naValue, nrow = 2L, ncol = 0L)
  +     dimnames(x) <- lapply(dim(x), FUN = function(n) letters[seq_len(n)])
  +     q <- rowQuantiles(x, probs = probs, type = type, useNames = TRUE)
  +     stopifnot(identical(dim(q), c(nrow(x), length(probs))))
  +     
  +     x <- matrix(naValue, nrow = 0L, ncol = 2L)
  +     dimnames(x) <- lapply(dim(x), FUN = function(n) letters[seq_len(n)])
  +     q <- colQuantiles(x, probs = probs, type = type, useNames = TRUE)
  +     stopifnot(identical(dim(q), c(ncol(x), length(probs))))
  + 
  + 
  +     # - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  +     # Single column matrices
  +     # - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  +     probs <- c(0, 0.25, 0.75, 1)
  +     x <- matrix(someValue, nrow = 2L, ncol = 1L)
  +     dimnames(x) <- lapply(dim(x), FUN = function(n) letters[seq_len(n)])
  +     qr <- rowQuantiles(x, probs = probs, type = type, useNames = TRUE)
  +     print(qr)
  +     
  +     x <- matrix(someValue, nrow = 1L, ncol = 2L)
  +     dimnames(x) <- lapply(dim(x), FUN = function(n) letters[seq_len(n)])
  +     qc <- colQuantiles(x, probs = probs, type = type, useNames = TRUE)
  +     print(qc)
  +     
  +     stopifnot(identical(qc, qr))
  +   }
  + }
    0% 25% 75% 100%
  a  1   1   1    1
  b  1   1   1    1
    0% 25% 75% 100%
  a  1   1   1    1
  b  1   1   1    1
    0% 25% 75% 100%
  a  1   1   1    1
  b  1   1   1    1
    0% 25% 75% 100%
  a  1   1   1    1
  b  1   1   1    1
    0% 25% 75% 100%
  a  1   1   1    1
  b  1   1   1    1
    0% 25% 75% 100%
  a  1   1   1    1
  b  1   1   1    1
    0% 25% 75% 100%
  a  1   1   1    1
  b  1   1   1    1
    0% 25% 75% 100%
  a  1   1   1    1
  b  1   1   1    1
    0% 25% 75% 100%
  a  1   1   1    1
  b  1   1   1    1
    0% 25% 75% 100%
  a  1   1   1    1
  b  1   1   1    1
    0% 25% 75% 100%
  a  1   1   1    1
  b  1   1   1    1
    0% 25% 75% 100%
  a  1   1   1    1
  b  1   1   1    1
    0% 25% 75% 100%
  a  1   1   1    1
  b  1   1   1    1
    0% 25% 75% 100%
  a  1   1   1    1
  b  1   1   1    1
    0% 25% 75% 100%
  a  1   1   1    1
  b  1   1   1    1
    0% 25% 75% 100%
  a  1   1   1    1
  b  1   1   1    1
    0% 25% 75% 100%
  a  1   1   1    1
  b  1   1   1    1
    0% 25% 75% 100%
  a  1   1   1    1
  b  1   1   1    1
    0% 25% 75% 100%
  a  1   1   1    1
  b  1   1   1    1
    0% 25% 75% 100%
  a  1   1   1    1
  b  1   1   1    1
    0% 25% 75% 100%
  a  1   1   1    1
  b  1   1   1    1
    0% 25% 75% 100%
  a  1   1   1    1
  b  1   1   1    1
    0% 25% 75% 100%
  a  1   1   1    1
  b  1   1   1    1
    0% 25% 75% 100%
  a  1   1   1    1
  b  1   1   1    1
    0% 25% 75% 100%
  a  1   1   1    1
  b  1   1   1    1
    0% 25% 75% 100%
  a  1   1   1    1
  b  1   1   1    1
    0% 25% 75% 100%
  a  1   1   1    1
  b  1   1   1    1
    0% 25% 75% 100%
  a  1   1   1    1
  b  1   1   1    1
    0% 25% 75% 100%
  a  1   1   1    1
  b  1   1   1    1
    0% 25% 75% 100%
  a  1   1   1    1
  b  1   1   1    1
    0% 25% 75% 100%
  a  1   1   1    1
  b  1   1   1    1
    0% 25% 75% 100%
  a  1   1   1    1
  b  1   1   1    1
    0% 25% 75% 100%
  a  1   1   1    1
  b  1   1   1    1
    0% 25% 75% 100%
  a  1   1   1    1
  b  1   1   1    1
    0% 25% 75% 100%
  a  1   1   1    1
  b  1   1   1    1
    0% 25% 75% 100%
  a  1   1   1    1
  b  1   1   1    1
    0% 25% 75% 100%
  a  1   1   1    1
  b  1   1   1    1
    0% 25% 75% 100%
  a  1   1   1    1
  b  1   1   1    1
    0% 25% 75% 100%
  a  1   1   1    1
  b  1   1   1    1
    0% 25% 75% 100%
  a  1   1   1    1
  b  1   1   1    1
    0% 25% 75% 100%
  a  1   1   1    1
  b  1   1   1    1
    0% 25% 75% 100%
  a  1   1   1    1
  b  1   1   1    1
    0% 25% 75% 100%
  a  1   1   1    1
  b  1   1   1    1
    0% 25% 75% 100%
  a  1   1   1    1
  b  1   1   1    1
    0% 25% 75% 100%
  a  1   1   1    1
  b  1   1   1    1
    0% 25% 75% 100%
  a  1   1   1    1
  b  1   1   1    1
    0% 25% 75% 100%
  a  1   1   1    1
  b  1   1   1    1
    0% 25% 75% 100%
  a  1   1   1    1
  b  1   1   1    1
    0% 25% 75% 100%
  a  1   1   1    1
  b  1   1   1    1
    0% 25% 75% 100%
  a  1   1   1    1
  b  1   1   1    1
    0% 25% 75% 100%
  a  1   1   1    1
  b  1   1   1    1
    0% 25% 75% 100%
  a  1   1   1    1
  b  1   1   1    1
    0% 25% 75% 100%
  a  1   1   1    1
  b  1   1   1    1
    0% 25% 75% 100%
  a  1   1   1    1
  b  1   1   1    1
  > 
  > proc.time()
     user  system elapsed 
    14.09    0.35   14.42 
Running the tests in 'tests/rowRanges.R' failed.
Complete output:
  > library("matrixStats")
  > 
  > rowMins_R <- function(x, ..., useNames = NA) {
  +   suppressWarnings({
  +     res <- apply(x, MARGIN = 1L, FUN = min, ...)
  +   })
  +   if (is.na(useNames) || !useNames) names(res) <- NULL
  +   res
  + } # rowMins_R()
  > 
  > rowMaxs_R <- function(x, ..., useNames = NA) {
  +   suppressWarnings({
  +     res <- apply(x, MARGIN = 1L, FUN = max, ...)
  +   })
  +   if (is.na(useNames) || !useNames) names(res) <- NULL
  +   res
  + } # rowMaxs_R()
  > 
  > rowRanges_R <- function(x, ..., useNames = NA) {
  +   suppressWarnings({
  +     ans <- t(apply(x, MARGIN = 1L, FUN = range, ...))
  +   })
  +   
  +   # Preserve rownames attribute
  +   dim <- c(dim(x)[1], 2L)
  +   if (!isTRUE(all.equal(dim(ans), dim))) {
  +     dim(ans) <- dim
  +     rownames <- rownames(x)
  +     if (!is.null(dimnames)) rownames(ans) <- rownames
  +   }
  +   if (is.na(useNames) || !useNames) dimnames(ans) <- NULL
  +   ans
  + } # rowRanges_R()
  > 
  > 
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > # With and without some NAs
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > for (mode in c("integer", "double")) {
  +   cat("mode: ", mode, "\n", sep = "")
  + 
  +   for (add_na in c(FALSE, TRUE)) {
  +     cat("add_na = ", add_na, "\n", sep = "")
  + 
  +     x <- matrix(1:50 + 0.1, nrow = 10L, ncol = 5L)
  +     if (add_na) {
  +       x[3:7, c(2, 4)] <- NA_real_
  +     }
  +     storage.mode(x) <- mode
  +     str(x)
  +     
  +     # To check names attribute
  +     dimnames <- list(letters[1:10], LETTERS[1:5])
  +     
  +     # Test with and without dimnames on x
  +     for (setDimnames in c(TRUE, FALSE)) {
  +       if (setDimnames) dimnames(x) <- dimnames
  +       else dimnames(x) <- NULL
  +       # Row/column extremes
  +       for (na.rm in c(FALSE, TRUE)) {
  +         # Check names attribute
  +         for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) {
  +           cat("na.rm = ", na.rm, "\n", sep = "")
  +           
  +           # Ranges
  +           cat("range:\n")
  +           r0 <- rowRanges_R(x, na.rm = na.rm, useNames = useNames)
  +           r1 <- rowRanges(x, na.rm = na.rm, useNames = useNames)
  +           r2 <- colRanges(t(x), na.rm = na.rm, useNames = useNames)
  +           stopifnot(all.equal(r1, r2))
  +           stopifnot(all.equal(r1, r0))
  +           
  +           # Min
  +           cat("min:\n")
  +           m0 <- rowMins_R(x, na.rm = na.rm, useNames = useNames)
  +           m1 <- rowMins(x, na.rm = na.rm, useNames = useNames)
  +           m2 <- colMins(t(x), na.rm = na.rm, useNames = useNames)
  +           stopifnot(all.equal(m1, m2))
  +           stopifnot(all.equal(m1, m0))
  +           
  +           # Max
  +           cat("max:\n")
  +           m0 <- rowMaxs_R(x, na.rm = na.rm, useNames = useNames)
  +           m1 <- rowMaxs(x, na.rm = na.rm, useNames = useNames)
  +           m2 <- colMaxs(t(x), na.rm = na.rm, useNames = useNames)
  +           stopifnot(all.equal(m1, m2))
  +           stopifnot(all.equal(m1, m0))
  +         }
  +       }
  +     }
  +   } # for (add_na ...)
  + } # for (mode ...)
  mode: integer
  add_na = FALSE
   int [1:10, 1:5] 1 2 3 4 5 6 7 8 9 10 ...
  na.rm = FALSE
  range:
  min:
  max:
  na.rm = FALSE
  range:
  min:
  max:
  na.rm = TRUE
  range:
  min:
  max:
  na.rm = TRUE
  range:
  min:
  max:
  na.rm = FALSE
  range:
  min:
  max:
  na.rm = FALSE
  range:
  min:
  max:
  na.rm = TRUE
  range:
  min:
  max:
  na.rm = TRUE
  range:
  min:
  max:
  add_na = TRUE
   int [1:10, 1:5] 1 2 3 4 5 6 7 8 9 10 ...
  na.rm = FALSE
  range:
  min:
  max:
  na.rm = FALSE
  range:
  min:
  max:
  na.rm = TRUE
  range:
  min:
  max:
  na.rm = TRUE
  range:
  min:
  max:
  na.rm = FALSE
  range:
  min:
  max:
  na.rm = FALSE
  range:
  min:
  max:
  na.rm = TRUE
  range:
  min:
  max:
  na.rm = TRUE
  range:
  min:
  max:
  mode: double
  add_na = FALSE
   num [1:10, 1:5] 1.1 2.1 3.1 4.1 5.1 6.1 7.1 8.1 9.1 10.1 ...
  na.rm = FALSE
  range:
  min:
  max:
  na.rm = FALSE
  range:
  min:
  max:
  na.rm = TRUE
  range:
  min:
  max:
  na.rm = TRUE
  range:
  min:
  max:
  na.rm = FALSE
  range:
  min:
  max:
  na.rm = FALSE
  range:
  min:
  max:
  na.rm = TRUE
  range:
  min:
  max:
  na.rm = TRUE
  range:
  min:
  max:
  add_na = TRUE
   num [1:10, 1:5] 1.1 2.1 3.1 4.1 5.1 6.1 7.1 8.1 9.1 10.1 ...
  na.rm = FALSE
  range:
  min:
  max:
  na.rm = FALSE
  range:
  min:
  max:
  na.rm = TRUE
  range:
  min:
  max:
  na.rm = TRUE
  range:
  min:
  max:
  na.rm = FALSE
  range:
  min:
  max:
  na.rm = FALSE
  range:
  min:
  max:
  na.rm = TRUE
  range:
  min:
  max:
  na.rm = TRUE
  range:
  min:
  max:
  > 
  > 
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > # All NAs
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > for (mode in c("integer", "double")) {
  +   cat("mode: ", mode, "\n", sep = "")
  +   x <- matrix(NA_real_, nrow = 10L, ncol = 5L)
  +   storage.mode(x) <- mode
  +   str(x)
  +   
  +   # Test with and without dimnames on x
  +   for (setDimnames in c(TRUE, FALSE)) {
  +     if (setDimnames) dimnames(x) <- dimnames
  +     else dimnames(x) <- NULL
  +     for (na.rm in c(FALSE, TRUE)) {
  +       # Check names attribute
  +       for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) {
  +         cat("na.rm = ", na.rm, "\n", sep = "")
  +         r0 <- rowRanges_R(x, na.rm = na.rm, useNames = useNames)
  +         r1 <- rowRanges(x, na.rm = na.rm, useNames = useNames)
  +         r2 <- colRanges(t(x), na.rm = na.rm, useNames = useNames)
  +         stopifnot(all.equal(r1, r2))
  +         stopifnot(all.equal(r1, r0))
  +       }
  +     }
  +   }
  + } # for (mode ...)
  mode: integer
   int [1:10, 1:5] NA NA NA NA NA NA NA NA NA NA ...
  na.rm = FALSE
  na.rm = FALSE
  na.rm = TRUE
  na.rm = TRUE
  na.rm = FALSE
  na.rm = FALSE
  na.rm = TRUE
  na.rm = TRUE
  mode: double
   num [1:10, 1:5] NA NA NA NA NA NA NA NA NA NA ...
  na.rm = FALSE
  na.rm = FALSE
  na.rm = TRUE
  na.rm = TRUE
  na.rm = FALSE
  na.rm = FALSE
  na.rm = TRUE
  na.rm = TRUE
  > 
  > 
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > # Special cases
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > # Nx0 matrix
  > x <- matrix(double(0L), nrow = 5L, ncol = 0L)
  > r0 <- rowRanges_R(x)
  > #r1 <- rowRanges(x)
  > #r_truth <- matrix(c(Inf, -Inf), nrow = nrow(x), ncol = 2L, byrow = TRUE)
  > #stopifnot(all.equal(r1, r_truth))
  > 
  > # 0xN matrix
  > x <- t(x)
  > #r1 <- colRanges(x)
  > #stopifnot(all.equal(r1, r_truth))
  > 
  > # Nx1 matrix
  > x <- matrix(1:5, nrow = 5L, ncol = 1L)
  > # To check names attribute
  > dimnames <- list(letters[1:5], "A")
  > r1 <- rowRanges(x)
  > r_truth <- matrix(1:5, nrow = nrow(x), ncol = 2L, byrow = FALSE)
  > stopifnot(all.equal(r1, r_truth))
  > # Check names attribute
  > dimnames(x) <- dimnames
  > r0 <- rowRanges_R(x, useNames = TRUE)
  > r1 <- rowRanges(x, useNames = TRUE)
  > stopifnot(all.equal(r1, r0))
  > dimnames(x) <- NULL
  > 
  > # 1xN matrix
  > x <- t(x)
  > r1 <- colRanges(x)
  > stopifnot(all.equal(r1, r_truth))
  > # Check names attribute
  > dimnames(x) <- list("a", LETTERS[1:5])
  > r1 <- colRanges(x, useNames = TRUE)
  > stopifnot(identical(rownames(r1), colnames(x)))
  > 
  > 
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > # Additional tests with NA_integer_, NA_real, NaN, -Inf, +Inf
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > x <- matrix(1:12, nrow = 4L, ncol = 3L)
  > 
  > na_list <- list(
  +   "integer"       = matrix(1:12, nrow = 4L, ncol = 3L),
  +   "integer w/ NA" = matrix(NA_integer_, nrow = 4L, ncol = 3L),
  +   "real"          = matrix(as.double(1:12), nrow = 4L, ncol = 3L),
  +   "real w/ NA"    = matrix(NA_real_, nrow = 4L, ncol = 3L)
  + )
  > 
  > na <- na_list[["real"]]
  > na[2, 2] <- NA
  > na_list[["real + NA cell"]] <- na
  > 
  > na <- na_list[["real"]]
  > na[2, ] <- NA
  > na_list[["real + NA row"]] <- na
  > 
  > na <- na_list[["real"]]
  > na[2, ] <- NaN
  > na_list[["real + NaN row"]] <- na
  > 
  > na <- na_list[["real"]]
  > na[2, 2] <- Inf
  > na_list[["real + Inf cell"]] <- na
  > 
  > na <- na_list[["real"]]
  > na[2, ] <- Inf
  > na_list[["real + Inf row"]] <- na
  > 
  > na <- na_list[["real"]]
  > na[2, 2] <- NaN
  > na_list[["real + NaN cell"]] <- na
  > 
  > na <- na_list[["real w/ NA"]]
  > na[2, 2] <- NaN
  > na_list[["real w/ NA + NaN cell"]] <- na
  > 
  > na <- na_list[["real w/ NA"]]
  > na[2, ] <- NaN
  > na_list[["real w/ NA + NaN row"]] <- na
  > 
  > # To check names attribute
  > dimnames <- list(letters[1:4], LETTERS[1:3])
  > 
  > # Test with and without dimnames on x
  > for (setDimnames in c(TRUE, FALSE)) {
  +   if (setDimnames) dimnames(x) <- dimnames
  +   else dimnames(x) <- NULL
  +   for (na.rm in c(FALSE, TRUE)) {
  +     for (name in names(na_list)) {
  +       # Check names attribute
  +       for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) {
  +         na <- na_list[[name]]
  +         cat(sprintf("%s (%s) w/ na.rm = %s:\n", name, typeof(na), na.rm))
  +         print(na)
  +         
  +         cat("  min:\n")
  +         y0 <- rowMins_R(na, na.rm = na.rm, useNames = useNames)
  +         str(y0)
  +         y1 <- rowMins(na, na.rm = na.rm, useNames = useNames)
  +         str(y1)
  +         stopifnot(all.equal(y1, y0))
  +         y1c <- colMins(t(na), na.rm = na.rm, useNames = useNames)
  +         str(y1c)
  +         stopifnot(all.equal(y1c, y1))
  +         
  +         cat("  max:\n")
  +         y0 <- rowMaxs_R(na, na.rm = na.rm, useNames = useNames)
  +         str(y0)
  +         y1 <- rowMaxs(na, na.rm = na.rm, useNames = useNames)
  +         str(y1)
  +         stopifnot(all.equal(y1, y0))
  +         y1c <- colMaxs(t(na), na.rm = na.rm, useNames = useNames)
  +         str(y1c)
  +         stopifnot(all.equal(y1c, y1))
  +         
  +         cat("  range:\n")
  +         y0 <- rowRanges_R(na, na.rm = na.rm, useNames = useNames)
  +         str(y0)
  +         y1 <- rowRanges(na, na.rm = na.rm, useNames = useNames)
  +         str(y1)
  +         stopifnot(all.equal(y1, y0))
  +         y1c <- colRanges(t(na), na.rm = na.rm, useNames = useNames)
  +         str(y1c)
  +         stopifnot(all.equal(y1c, y1))
  +       }
  +     } # for (name ...)
  +   } # for (na.rm ...)
  + }
  integer (integer) w/ na.rm = FALSE:
       [,1] [,2] [,3]
  [1,]    1    5    9
  [2,]    2    6   10
  [3,]    3    7   11
  [4,]    4    8   12
    min:
   int [1:4] 1 2 3 4
   int [1:4] 1 2 3 4
   int [1:4] 1 2 3 4
    max:
   int [1:4] 9 10 11 12
   int [1:4] 9 10 11 12
   int [1:4] 9 10 11 12
    range:
   int [1:4, 1:2] 1 2 3 4 9 10 11 12
   int [1:4, 1:2] 1 2 3 4 9 10 11 12
   int [1:4, 1:2] 1 2 3 4 9 10 11 12
  integer (integer) w/ na.rm = FALSE:
       [,1] [,2] [,3]
  [1,]    1    5    9
  [2,]    2    6   10
  [3,]    3    7   11
  [4,]    4    8   12
    min:
   int [1:4] 1 2 3 4
   int [1:4] 1 2 3 4
   int [1:4] 1 2 3 4
    max:
   int [1:4] 9 10 11 12
   int [1:4] 9 10 11 12
   int [1:4] 9 10 11 12
    range:
   int [1:4, 1:2] 1 2 3 4 9 10 11 12
   int [1:4, 1:2] 1 2 3 4 9 10 11 12
   int [1:4, 1:2] 1 2 3 4 9 10 11 12
  integer w/ NA (integer) w/ na.rm = FALSE:
       [,1] [,2] [,3]
  [1,]   NA   NA   NA
  [2,]   NA   NA   NA
  [3,]   NA   NA   NA
  [4,]   NA   NA   NA
    min:
   int [1:4] NA NA NA NA
   int [1:4] NA NA NA NA
   int [1:4] NA NA NA NA
    max:
   int [1:4] NA NA NA NA
   int [1:4] NA NA NA NA
   int [1:4] NA NA NA NA
    range:
   int [1:4, 1:2] NA NA NA NA NA NA NA NA
   int [1:4, 1:2] NA NA NA NA NA NA NA NA
   int [1:4, 1:2] NA NA NA NA NA NA NA NA
  integer w/ NA (integer) w/ na.rm = FALSE:
       [,1] [,2] [,3]
  [1,]   NA   NA   NA
  [2,]   NA   NA   NA
  [3,]   NA   NA   NA
  [4,]   NA   NA   NA
    min:
   int [1:4] NA NA NA NA
   int [1:4] NA NA NA NA
   int [1:4] NA NA NA NA
    max:
   int [1:4] NA NA NA NA
   int [1:4] NA NA NA NA
   int [1:4] NA NA NA NA
    range:
   int [1:4, 1:2] NA NA NA NA NA NA NA NA
   int [1:4, 1:2] NA NA NA NA NA NA NA NA
   int [1:4, 1:2] NA NA NA NA NA NA NA NA
  real (double) w/ na.rm = FALSE:
       [,1] [,2] [,3]
  [1,]    1    5    9
  [2,]    2    6   10
  [3,]    3    7   11
  [4,]    4    8   12
    min:
   num [1:4] 1 2 3 4
   num [1:4] 1 2 3 4
   num [1:4] 1 2 3 4
    max:
   num [1:4] 9 10 11 12
   num [1:4] 9 10 11 12
   num [1:4] 9 10 11 12
    range:
   num [1:4, 1:2] 1 2 3 4 9 10 11 12
   num [1:4, 1:2] 1 2 3 4 9 10 11 12
   num [1:4, 1:2] 1 2 3 4 9 10 11 12
  real (double) w/ na.rm = FALSE:
       [,1] [,2] [,3]
  [1,]    1    5    9
  [2,]    2    6   10
  [3,]    3    7   11
  [4,]    4    8   12
    min:
   num [1:4] 1 2 3 4
   num [1:4] 1 2 3 4
   num [1:4] 1 2 3 4
    max:
   num [1:4] 9 10 11 12
   num [1:4] 9 10 11 12
   num [1:4] 9 10 11 12
    range:
   num [1:4, 1:2] 1 2 3 4 9 10 11 12
   num [1:4, 1:2] 1 2 3 4 9 10 11 12
   num [1:4, 1:2] 1 2 3 4 9 10 11 12
  real w/ NA (double) w/ na.rm = FALSE:
       [,1] [,2] [,3]
  [1,]   NA   NA   NA
  [2,]   NA   NA   NA
  [3,]   NA   NA   NA
  [4,]   NA   NA   NA
    min:
   num [1:4] NA NA NA NA
   num [1:4] NA NA NA NA
   num [1:4] NA NA NA NA
    max:
   num [1:4] NA NA NA NA
   num [1:4] NA NA NA NA
   num [1:4] NA NA NA NA
    range:
   num [1:4, 1:2] NA NA NA NA NA NA NA NA
   num [1:4, 1:2] NA NA NA NA NA NA NA NA
   num [1:4, 1:2] NA NA NA NA NA NA NA NA
  real w/ NA (double) w/ na.rm = FALSE:
       [,1] [,2] [,3]
  [1,]   NA   NA   NA
  [2,]   NA   NA   NA
  [3,]   NA   NA   NA
  [4,]   NA   NA   NA
    min:
   num [1:4] NA NA NA NA
   num [1:4] NA NA NA NA
   num [1:4] NA NA NA NA
    max:
   num [1:4] NA NA NA NA
   num [1:4] NA NA NA NA
   num [1:4] NA NA NA NA
    range:
   num [1:4, 1:2] NA NA NA NA NA NA NA NA
   num [1:4, 1:2] NA NA NA NA NA NA NA NA
   num [1:4, 1:2] NA NA NA NA NA NA NA NA
  real + NA cell (double) w/ na.rm = FALSE:
       [,1] [,2] [,3]
  [1,]    1    5    9
  [2,]    2   NA   10
  [3,]    3    7   11
  [4,]    4    8   12
    min:
   num [1:4] 1 NA 3 4
   num [1:4] 1 NA 3 4
   num [1:4] 1 NA 3 4
    max:
   num [1:4] 9 NA 11 12
   num [1:4] 9 NA 11 12
   num [1:4] 9 NA 11 12
    range:
   num [1:4, 1:2] 1 NA 3 4 9 NA 11 12
   num [1:4, 1:2] 1 NA 3 4 9 NA 11 12
   num [1:4, 1:2] 1 NA 3 4 9 NA 11 12
  real + NA cell (double) w/ na.rm = FALSE:
       [,1] [,2] [,3]
  [1,]    1    5    9
  [2,]    2   NA   10
  [3,]    3    7   11
  [4,]    4    8   12
    min:
   num [1:4] 1 NA 3 4
   num [1:4] 1 NA 3 4
   num [1:4] 1 NA 3 4
    max:
   num [1:4] 9 NA 11 12
   num [1:4] 9 NA 11 12
   num [1:4] 9 NA 11 12
    range:
   num [1:4, 1:2] 1 NA 3 4 9 NA 11 12
   num [1:4, 1:2] 1 NA 3 4 9 NA 11 12
   num [1:4, 1:2] 1 NA 3 4 9 NA 11 12
  real + NA row (double) w/ na.rm = FALSE:
       [,1] [,2] [,3]
  [1,]    1    5    9
  [2,]   NA   NA   NA
  [3,]    3    7   11
  [4,]    4    8   12
    min:
   num [1:4] 1 NA 3 4
   num [1:4] 1 NA 3 4
   num [1:4] 1 NA 3 4
    max:
   num [1:4] 9 NA 11 12
   num [1:4] 9 NA 11 12
   num [1:4] 9 NA 11 12
    range:
   num [1:4, 1:2] 1 NA 3 4 9 NA 11 12
   num [1:4, 1:2] 1 NA 3 4 9 NA 11 12
   num [1:4, 1:2] 1 NA 3 4 9 NA 11 12
  real + NA row (double) w/ na.rm = FALSE:
       [,1] [,2] [,3]
  [1,]    1    5    9
  [2,]   NA   NA   NA
  [3,]    3    7   11
  [4,]    4    8   12
    min:
   num [1:4] 1 NA 3 4
   num [1:4] 1 NA 3 4
   num [1:4] 1 NA 3 4
    max:
   num [1:4] 9 NA 11 12
   num [1:4] 9 NA 11 12
   num [1:4] 9 NA 11 12
    range:
   num [1:4, 1:2] 1 NA 3 4 9 NA 11 12
   num [1:4, 1:2] 1 NA 3 4 9 NA 11 12
   num [1:4, 1:2] 1 NA 3 4 9 NA 11 12
  real + NaN row (double) w/ na.rm = FALSE:
       [,1] [,2] [,3]
  [1,]    1    5    9
  [2,]  NaN  NaN  NaN
  [3,]    3    7   11
  [4,]    4    8   12
    min:
   num [1:4] 1 NaN 3 4
   num [1:4] 1 NaN 3 4
   num [1:4] 1 NaN 3 4
    max:
   num [1:4] 9 NaN 11 12
   num [1:4] 9 NaN 11 12
   num [1:4] 9 NaN 11 12
    range:
   num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12
   num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12
   num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12
  real + NaN row (double) w/ na.rm = FALSE:
       [,1] [,2] [,3]
  [1,]    1    5    9
  [2,]  NaN  NaN  NaN
  [3,]    3    7   11
  [4,]    4    8   12
    min:
   num [1:4] 1 NaN 3 4
   num [1:4] 1 NaN 3 4
   num [1:4] 1 NaN 3 4
    max:
   num [1:4] 9 NaN 11 12
   num [1:4] 9 NaN 11 12
   num [1:4] 9 NaN 11 12
    range:
   num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12
   num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12
   num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12
  real + Inf cell (double) w/ na.rm = FALSE:
       [,1] [,2] [,3]
  [1,]    1    5    9
  [2,]    2  Inf   10
  [3,]    3    7   11
  [4,]    4    8   12
    min:
   num [1:4] 1 2 3 4
   num [1:4] 1 2 3 4
   num [1:4] 1 2 3 4
    max:
   num [1:4] 9 Inf 11 12
   num [1:4] 9 Inf 11 12
   num [1:4] 9 Inf 11 12
    range:
   num [1:4, 1:2] 1 2 3 4 9 ...
   num [1:4, 1:2] 1 2 3 4 9 ...
   num [1:4, 1:2] 1 2 3 4 9 ...
  real + Inf cell (double) w/ na.rm = FALSE:
       [,1] [,2] [,3]
  [1,]    1    5    9
  [2,]    2  Inf   10
  [3,]    3    7   11
  [4,]    4    8   12
    min:
   num [1:4] 1 2 3 4
   num [1:4] 1 2 3 4
   num [1:4] 1 2 3 4
    max:
   num [1:4] 9 Inf 11 12
   num [1:4] 9 Inf 11 12
   num [1:4] 9 Inf 11 12
    range:
   num [1:4, 1:2] 1 2 3 4 9 ...
   num [1:4, 1:2] 1 2 3 4 9 ...
   num [1:4, 1:2] 1 2 3 4 9 ...
  real + Inf row (double) w/ na.rm = FALSE:
       [,1] [,2] [,3]
  [1,]    1    5    9
  [2,]  Inf  Inf  Inf
  [3,]    3    7   11
  [4,]    4    8   12
    min:
   num [1:4] 1 Inf 3 4
   num [1:4] 1 Inf 3 4
   num [1:4] 1 Inf 3 4
    max:
   num [1:4] 9 Inf 11 12
   num [1:4] 9 Inf 11 12
   num [1:4] 9 Inf 11 12
    range:
   num [1:4, 1:2] 1 Inf 3 4 9 ...
   num [1:4, 1:2] 1 Inf 3 4 9 ...
   num [1:4, 1:2] 1 Inf 3 4 9 ...
  real + Inf row (double) w/ na.rm = FALSE:
       [,1] [,2] [,3]
  [1,]    1    5    9
  [2,]  Inf  Inf  Inf
  [3,]    3    7   11
  [4,]    4    8   12
    min:
   num [1:4] 1 Inf 3 4
   num [1:4] 1 Inf 3 4
   num [1:4] 1 Inf 3 4
    max:
   num [1:4] 9 Inf 11 12
   num [1:4] 9 Inf 11 12
   num [1:4] 9 Inf 11 12
    range:
   num [1:4, 1:2] 1 Inf 3 4 9 ...
   num [1:4, 1:2] 1 Inf 3 4 9 ...
   num [1:4, 1:2] 1 Inf 3 4 9 ...
  real + NaN cell (double) w/ na.rm = FALSE:
       [,1] [,2] [,3]
  [1,]    1    5    9
  [2,]    2  NaN   10
  [3,]    3    7   11
  [4,]    4    8   12
    min:
   num [1:4] 1 NaN 3 4
   num [1:4] 1 NaN 3 4
   num [1:4] 1 NaN 3 4
    max:
   num [1:4] 9 NaN 11 12
   num [1:4] 9 NaN 11 12
   num [1:4] 9 NaN 11 12
    range:
   num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12
   num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12
   num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12
  real + NaN cell (double) w/ na.rm = FALSE:
       [,1] [,2] [,3]
  [1,]    1    5    9
  [2,]    2  NaN   10
  [3,]    3    7   11
  [4,]    4    8   12
    min:
   num [1:4] 1 NaN 3 4
   num [1:4] 1 NaN 3 4
   num [1:4] 1 NaN 3 4
    max:
   num [1:4] 9 NaN 11 12
   num [1:4] 9 NaN 11 12
   num [1:4] 9 NaN 11 12
    range:
   num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12
   num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12
   num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12
  real w/ NA + NaN cell (double) w/ na.rm = FALSE:
       [,1] [,2] [,3]
  [1,]   NA   NA   NA
  [2,]   NA  NaN   NA
  [3,]   NA   NA   NA
  [4,]   NA   NA   NA
    min:
   num [1:4] NA NA NA NA
   num [1:4] NA NA NA NA
   num [1:4] NA NA NA NA
    max:
   num [1:4] NA NA NA NA
   num [1:4] NA NA NA NA
   num [1:4] NA NA NA NA
    range:
   num [1:4, 1:2] NA NA NA NA NA NA NA NA
   num [1:4, 1:2] NA NA NA NA NA NA NA NA
   num [1:4, 1:2] NA NA NA NA NA NA NA NA
  real w/ NA + NaN cell (double) w/ na.rm = FALSE:
       [,1] [,2] [,3]
  [1,]   NA   NA   NA
  [2,]   NA  NaN   NA
  [3,]   NA   NA   NA
  [4,]   NA   NA   NA
    min:
   num [1:4] NA NA NA NA
   num [1:4] NA NA NA NA
   num [1:4] NA NA NA NA
    max:
   num [1:4] NA NA NA NA
   num [1:4] NA NA NA NA
   num [1:4] NA NA NA NA
    range:
   num [1:4, 1:2] NA NA NA NA NA NA NA NA
   num [1:4, 1:2] NA NA NA NA NA NA NA NA
   num [1:4, 1:2] NA NA NA NA NA NA NA NA
  real w/ NA + NaN row (double) w/ na.rm = FALSE:
       [,1] [,2] [,3]
  [1,]   NA   NA   NA
  [2,]  NaN  NaN  NaN
  [3,]   NA   NA   NA
  [4,]   NA   NA   NA
    min:
   num [1:4] NA NaN NA NA
   num [1:4] NA NaN NA NA
   num [1:4] NA NaN NA NA
    max:
   num [1:4] NA NaN NA NA
   num [1:4] NA NaN NA NA
   num [1:4] NA NaN NA NA
    range:
   num [1:4, 1:2] NA NaN NA NA NA NaN NA NA
   num [1:4, 1:2] NA NaN NA NA NA NaN NA NA
   num [1:4, 1:2] NA NaN NA NA NA NaN NA NA
  real w/ NA + NaN row (double) w/ na.rm = FALSE:
       [,1] [,2] [,3]
  [1,]   NA   NA   NA
  [2,]  NaN  NaN  NaN
  [3,]   NA   NA   NA
  [4,]   NA   NA   NA
    min:
   num [1:4] NA NaN NA NA
   num [1:4] NA NaN NA NA
   num [1:4] NA NaN NA NA
    max:
   num [1:4] NA NaN NA NA
   num [1:4] NA NaN NA NA
   num [1:4] NA NaN NA NA
    range:
   num [1:4, 1:2] NA NaN NA NA NA NaN NA NA
   num [1:4, 1:2] NA NaN NA NA NA NaN NA NA
   num [1:4, 1:2] NA NaN NA NA NA NaN NA NA
  integer (integer) w/ na.rm = TRUE:
       [,1] [,2] [,3]
  [1,]    1    5    9
  [2,]    2    6   10
  [3,]    3    7   11
  [4,]    4    8   12
    min:
   int [1:4] 1 2 3 4
   int [1:4] 1 2 3 4
   int [1:4] 1 2 3 4
    max:
   int [1:4] 9 10 11 12
   int [1:4] 9 10 11 12
   int [1:4] 9 10 11 12
    range:
   int [1:4, 1:2] 1 2 3 4 9 10 11 12
   int [1:4, 1:2] 1 2 3 4 9 10 11 12
   int [1:4, 1:2] 1 2 3 4 9 10 11 12
  integer (integer) w/ na.rm = TRUE:
       [,1] [,2] [,3]
  [1,]    1    5    9
  [2,]    2    6   10
  [3,]    3    7   11
  [4,]    4    8   12
    min:
   int [1:4] 1 2 3 4
   int [1:4] 1 2 3 4
   int [1:4] 1 2 3 4
    max:
   int [1:4] 9 10 11 12
   int [1:4] 9 10 11 12
   int [1:4] 9 10 11 12
    range:
   int [1:4, 1:2] 1 2 3 4 9 10 11 12
   int [1:4, 1:2] 1 2 3 4 9 10 11 12
   int [1:4, 1:2] 1 2 3 4 9 10 11 12
  integer w/ NA (integer) w/ na.rm = TRUE:
       [,1] [,2] [,3]
  [1,]   NA   NA   NA
  [2,]   NA   NA   NA
  [3,]   NA   NA   NA
  [4,]   NA   NA   NA
    min:
   num [1:4] Inf Inf Inf Inf
   num [1:4] Inf Inf Inf Inf
   num [1:4] Inf Inf Inf Inf
    max:
   num [1:4] -Inf -Inf -Inf -Inf
   num [1:4] -Inf -Inf -Inf -Inf
   num [1:4] -Inf -Inf -Inf -Inf
    range:
   num [1:4, 1:2] Inf Inf Inf Inf -Inf ...
   num [1:4, 1:2] Inf Inf Inf Inf -Inf ...
   num [1:4, 1:2] Inf Inf Inf Inf -Inf ...
  integer w/ NA (integer) w/ na.rm = TRUE:
       [,1] [,2] [,3]
  [1,]   NA   NA   NA
  [2,]   NA   NA   NA
  [3,]   NA   NA   NA
  [4,]   NA   NA   NA
    min:
   num [1:4] Inf Inf Inf Inf
   num [1:4] Inf Inf Inf Inf
   num [1:4] Inf Inf Inf Inf
    max:
   num [1:4] -Inf -Inf -Inf -Inf
   num [1:4] -Inf -Inf -Inf -Inf
   num [1:4] -Inf -Inf -Inf -Inf
    range:
   num [1:4, 1:2] Inf Inf Inf Inf -Inf ...
   num [1:4, 1:2] Inf Inf Inf Inf -Inf ...
   num [1:4, 1:2] Inf Inf Inf Inf -Inf ...
  real (double) w/ na.rm = TRUE:
       [,1] [,2] [,3]
  [1,]    1    5    9
  [2,]    2    6   10
  [3,]    3    7   11
  [4,]    4    8   12
    min:
   num [1:4] 1 2 3 4
   num [1:4] 1 2 3 4
   num [1:4] 1 2 3 4
    max:
   num [1:4] 9 10 11 12
   num [1:4] 9 10 11 12
   num [1:4] 9 10 11 12
    range:
   num [1:4, 1:2] 1 2 3 4 9 10 11 12
   num [1:4, 1:2] 1 2 3 4 9 10 11 12
   num [1:4, 1:2] 1 2 3 4 9 10 11 12
  real (double) w/ na.rm = TRUE:
       [,1] [,2] [,3]
  [1,]    1    5    9
  [2,]    2    6   10
  [3,]    3    7   11
  [4,]    4    8   12
    min:
   num [1:4] 1 2 3 4
   num [1:4] 1 2 3 4
   num [1:4] 1 2 3 4
    max:
   num [1:4] 9 10 11 12
   num [1:4] 9 10 11 12
   num [1:4] 9 10 11 12
    range:
   num [1:4, 1:2] 1 2 3 4 9 10 11 12
   num [1:4, 1:2] 1 2 3 4 9 10 11 12
   num [1:4, 1:2] 1 2 3 4 9 10 11 12
  real w/ NA (double) w/ na.rm = TRUE:
       [,1] [,2] [,3]
  [1,]   NA   NA   NA
  [2,]   NA   NA   NA
  [3,]   NA   NA   NA
  [4,]   NA   NA   NA
    min:
   num [1:4] Inf Inf Inf Inf
   num [1:4] Inf Inf Inf Inf
   num [1:4] Inf Inf Inf Inf
    max:
   num [1:4] -Inf -Inf -Inf -Inf
   num [1:4] -Inf -Inf -Inf -Inf
   num [1:4] -Inf -Inf -Inf -Inf
    range:
   num [1:4, 1:2] Inf Inf Inf Inf -Inf ...
   num [1:4, 1:2] Inf Inf Inf Inf -Inf ...
   num [1:4, 1:2] Inf Inf Inf Inf -Inf ...
  real w/ NA (double) w/ na.rm = TRUE:
       [,1] [,2] [,3]
  [1,]   NA   NA   NA
  [2,]   NA   NA   NA
  [3,]   NA   NA   NA
  [4,]   NA   NA   NA
    min:
   num [1:4] Inf Inf Inf Inf
   num [1:4] Inf Inf Inf Inf
   num [1:4] Inf Inf Inf Inf
    max:
   num [1:4] -Inf -Inf -Inf -Inf
   num [1:4] -Inf -Inf -Inf -Inf
   num [1:4] -Inf -Inf -Inf -Inf
    range:
   num [1:4, 1:2] Inf Inf Inf Inf -Inf ...
   num [1:4, 1:2] Inf Inf Inf Inf -Inf ...
   num [1:4, 1:2] Inf Inf Inf Inf -Inf ...
  real + NA cell (double) w/ na.rm = TRUE:
       [,1] [,2] [,3]
  [1,]    1    5    9
  [2,]    2   NA   10
  [3,]    3    7   11
  [4,]    4    8   12
    min:
   num [1:4] 1 2 3 4
   num [1:4] 1 2 3 4
   num [1:4] 1 2 3 4
    max:
   num [1:4] 9 10 11 12
   num [1:4] 9 10 11 12
   num [1:4] 9 10 11 12
    range:
   num [1:4, 1:2] 1 2 3 4 9 10 11 12
   num [1:4, 1:2] 1 2 3 4 9 10 11 12
   num [1:4, 1:2] 1 2 3 4 9 10 11 12
  real + NA cell (double) w/ na.rm = TRUE:
       [,1] [,2] [,3]
  [1,]    1    5    9
  [2,]    2   NA   10
  [3,]    3    7   11
  [4,]    4    8   12
    min:
   num [1:4] 1 2 3 4
   num [1:4] 1 2 3 4
   num [1:4] 1 2 3 4
    max:
   num [1:4] 9 10 11 12
   num [1:4] 9 10 11 12
   num [1:4] 9 10 11 12
    range:
   num [1:4, 1:2] 1 2 3 4 9 10 11 12
   num [1:4, 1:2] 1 2 3 4 9 10 11 12
   num [1:4, 1:2] 1 2 3 4 9 10 11 12
  real + NA row (double) w/ na.rm = TRUE:
       [,1] [,2] [,3]
  [1,]    1    5    9
  [2,]   NA   NA   NA
  [3,]    3    7   11
  [4,]    4    8   12
    min:
   num [1:4] 1 Inf 3 4
   num [1:4] 1 Inf 3 4
   num [1:4] 1 Inf 3 4
    max:
   num [1:4] 9 -Inf 11 12
   num [1:4] 9 -Inf 11 12
   num [1:4] 9 -Inf 11 12
    range:
   num [1:4, 1:2] 1 Inf 3 4 9 ...
   num [1:4, 1:2] 1 Inf 3 4 9 ...
   num [1:4, 1:2] 1 Inf 3 4 9 ...
  real + NA row (double) w/ na.rm = TRUE:
       [,1] [,2] [,3]
  [1,]    1    5    9
  [2,]   NA   NA   NA
  [3,]    3    7   11
  [4,]    4    8   12
    min:
   num [1:4] 1 Inf 3 4
   num [1:4] 1 Inf 3 4
   num [1:4] 1 Inf 3 4
    max:
   num [1:4] 9 -Inf 11 12
   num [1:4] 9 -Inf 11 12
   num [1:4] 9 -Inf 11 12
    range:
   num [1:4, 1:2] 1 Inf 3 4 9 ...
   num [1:4, 1:2] 1 Inf 3 4 9 ...
   num [1:4, 1:2] 1 Inf 3 4 9 ...
  real + NaN row (double) w/ na.rm = TRUE:
       [,1] [,2] [,3]
  [1,]    1    5    9
  [2,]  NaN  NaN  NaN
  [3,]    3    7   11
  [4,]    4    8   12
    min:
   num [1:4] 1 Inf 3 4
   num [1:4] 1 Inf 3 4
   num [1:4] 1 Inf 3 4
    max:
   num [1:4] 9 -Inf 11 12
   num [1:4] 9 -Inf 11 12
   num [1:4] 9 -Inf 11 12
    range:
   num [1:4, 1:2] 1 Inf 3 4 9 ...
   num [1:4, 1:2] 1 Inf 3 4 9 ...
   num [1:4, 1:2] 1 Inf 3 4 9 ...
  real + NaN row (double) w/ na.rm = TRUE:
       [,1] [,2] [,3]
  [1,]    1    5    9
  [2,]  NaN  NaN  NaN
  [3,]    3    7   11
  [4,]    4    8   12
    min:
   num [1:4] 1 Inf 3 4
   num [1:4] 1 Inf 3 4
   num [1:4] 1 Inf 3 4
    max:
   num [1:4] 9 -Inf 11 12
   num [1:4] 9 -Inf 11 12
   num [1:4] 9 -Inf 11 12
    range:
   num [1:4, 1:2] 1 Inf 3 4 9 ...
   num [1:4, 1:2] 1 Inf 3 4 9 ...
   num [1:4, 1:2] 1 Inf 3 4 9 ...
  real + Inf cell (double) w/ na.rm = TRUE:
       [,1] [,2] [,3]
  [1,]    1    5    9
  [2,]    2  Inf   10
  [3,]    3    7   11
  [4,]    4    8   12
    min:
   num [1:4] 1 2 3 4
   num [1:4] 1 2 3 4
   num [1:4] 1 2 3 4
    max:
   num [1:4] 9 Inf 11 12
   num [1:4] 9 Inf 11 12
   num [1:4] 9 Inf 11 12
    range:
   num [1:4, 1:2] 1 2 3 4 9 ...
   num [1:4, 1:2] 1 2 3 4 9 ...
   num [1:4, 1:2] 1 2 3 4 9 ...
  real + Inf cell (double) w/ na.rm = TRUE:
       [,1] [,2] [,3]
  [1,]    1    5    9
  [2,]    2  Inf   10
  [3,]    3    7   11
  [4,]    4    8   12
    min:
   num [1:4] 1 2 3 4
   num [1:4] 1 2 3 4
   num [1:4] 1 2 3 4
    max:
   num [1:4] 9 Inf 11 12
   num [1:4] 9 Inf 11 12
   num [1:4] 9 Inf 11 12
    range:
   num [1:4, 1:2] 1 2 3 4 9 ...
   num [1:4, 1:2] 1 2 3 4 9 ...
   num [1:4, 1:2] 1 2 3 4 9 ...
  real + Inf row (double) w/ na.rm = TRUE:
       [,1] [,2] [,3]
  [1,]    1    5    9
  [2,]  Inf  Inf  Inf
  [3,]    3    7   11
  [4,]    4    8   12
    min:
   num [1:4] 1 Inf 3 4
   num [1:4] 1 Inf 3 4
   num [1:4] 1 Inf 3 4
    max:
   num [1:4] 9 Inf 11 12
   num [1:4] 9 Inf 11 12
   num [1:4] 9 Inf 11 12
    range:
   num [1:4, 1:2] 1 Inf 3 4 9 ...
   num [1:4, 1:2] 1 Inf 3 4 9 ...
   num [1:4, 1:2] 1 Inf 3 4 9 ...
  real + Inf row (double) w/ na.rm = TRUE:
       [,1] [,2] [,3]
  [1,]    1    5    9
  [2,]  Inf  Inf  Inf
  [3,]    3    7   11
  [4,]    4    8   12
    min:
   num [1:4] 1 Inf 3 4
   num [1:4] 1 Inf 3 4
   num [1:4] 1 Inf 3 4
    max:
   num [1:4] 9 Inf 11 12
   num [1:4] 9 Inf 11 12
   num [1:4] 9 Inf 11 12
    range:
   num [1:4, 1:2] 1 Inf 3 4 9 ...
   num [1:4, 1:2] 1 Inf 3 4 9 ...
   num [1:4, 1:2] 1 Inf 3 4 9 ...
  real + NaN cell (double) w/ na.rm = TRUE:
       [,1] [,2] [,3]
  [1,]    1    5    9
  [2,]    2  NaN   10
  [3,]    3    7   11
  [4,]    4    8   12
    min:
   num [1:4] 1 2 3 4
   num [1:4] 1 2 3 4
   num [1:4] 1 2 3 4
    max:
   num [1:4] 9 10 11 12
   num [1:4] 9 10 11 12
   num [1:4] 9 10 11 12
    range:
   num [1:4, 1:2] 1 2 3 4 9 10 11 12
   num [1:4, 1:2] 1 2 3 4 9 10 11 12
   num [1:4, 1:2] 1 2 3 4 9 10 11 12
  real + NaN cell (double) w/ na.rm = TRUE:
       [,1] [,2] [,3]
  [1,]    1    5    9
  [2,]    2  NaN   10
  [3,]    3    7   11
  [4,]    4    8   12
    min:
   num [1:4] 1 2 3 4
   num [1:4] 1 2 3 4
   num [1:4] 1 2 3 4
    max:
   num [1:4] 9 10 11 12
   num [1:4] 9 10 11 12
   num [1:4] 9 10 11 12
    range:
   num [1:4, 1:2] 1 2 3 4 9 10 11 12
   num [1:4, 1:2] 1 2 3 4 9 10 11 12
   num [1:4, 1:2] 1 2 3 4 9 10 11 12
  real w/ NA + NaN cell (double) w/ na.rm = TRUE:
       [,1] [,2] [,3]
  [1,]   NA   NA   NA
  [2,]   NA  NaN   NA
  [3,]   NA   NA   NA
  [4,]   NA   NA   NA
    min:
   num [1:4] Inf Inf Inf Inf
   num [1:4] Inf Inf Inf Inf
   num [1:4] Inf Inf Inf Inf
    max:
   num [1:4] -Inf -Inf -Inf -Inf
   num [1:4] -Inf -Inf -Inf -Inf
   num [1:4] -Inf -Inf -Inf -Inf
    range:
   num [1:4, 1:2] Inf Inf Inf Inf -Inf ...
   num [1:4, 1:2] Inf Inf Inf Inf -Inf ...
   num [1:4, 1:2] Inf Inf Inf Inf -Inf ...
  real w/ NA + NaN cell (double) w/ na.rm = TRUE:
       [,1] [,2] [,3]
  [1,]   NA   NA   NA
  [2,]   NA  NaN   NA
  [3,]   NA   NA   NA
  [4,]   NA   NA   NA
    min:
   num [1:4] Inf Inf Inf Inf
   num [1:4] Inf Inf Inf Inf
   num [1:4] Inf Inf Inf Inf
    max:
   num [1:4] -Inf -Inf -Inf -Inf
   num [1:4] -Inf -Inf -Inf -Inf
   num [1:4] -Inf -Inf -Inf -Inf
    range:
   num [1:4, 1:2] Inf Inf Inf Inf -Inf ...
   num [1:4, 1:2] Inf Inf Inf Inf -Inf ...
   num [1:4, 1:2] Inf Inf Inf Inf -Inf ...
  real w/ NA + NaN row (double) w/ na.rm = TRUE:
       [,1] [,2] [,3]
  [1,]   NA   NA   NA
  [2,]  NaN  NaN  NaN
  [3,]   NA   NA   NA
  [4,]   NA   NA   NA
    min:
   num [1:4] Inf Inf Inf Inf
   num [1:4] Inf Inf Inf Inf
   num [1:4] Inf Inf Inf Inf
    max:
   num [1:4] -Inf -Inf -Inf -Inf
   num [1:4] -Inf -Inf -Inf -Inf
   num [1:4] -Inf -Inf -Inf -Inf
    range:
   num [1:4, 1:2] Inf Inf Inf Inf -Inf ...
   num [1:4, 1:2] Inf Inf Inf Inf -Inf ...
   num [1:4, 1:2] Inf Inf Inf Inf -Inf ...
  real w/ NA + NaN row (double) w/ na.rm = TRUE:
       [,1] [,2] [,3]
  [1,]   NA   NA   NA
  [2,]  NaN  NaN  NaN
  [3,]   NA   NA   NA
  [4,]   NA   NA   NA
    min:
   num [1:4] Inf Inf Inf Inf
   num [1:4] Inf Inf Inf Inf
   num [1:4] Inf Inf Inf Inf
    max:
   num [1:4] -Inf -Inf -Inf -Inf
   num [1:4] -Inf -Inf -Inf -Inf
   num [1:4] -Inf -Inf -Inf -Inf
    range:
   num [1:4, 1:2] Inf Inf Inf Inf -Inf ...
   num [1:4, 1:2] Inf Inf Inf Inf -Inf ...
   num [1:4, 1:2] Inf Inf Inf Inf -Inf ...
  integer (integer) w/ na.rm = FALSE:
       [,1] [,2] [,3]
  [1,]    1    5    9
  [2,]    2    6   10
  [3,]    3    7   11
  [4,]    4    8   12
    min:
   int [1:4] 1 2 3 4
   int [1:4] 1 2 3 4
   int [1:4] 1 2 3 4
    max:
   int [1:4] 9 10 11 12
   int [1:4] 9 10 11 12
   int [1:4] 9 10 11 12
    range:
   int [1:4, 1:2] 1 2 3 4 9 10 11 12
   int [1:4, 1:2] 1 2 3 4 9 10 11 12
   int [1:4, 1:2] 1 2 3 4 9 10 11 12
  integer (integer) w/ na.rm = FALSE:
       [,1] [,2] [,3]
  [1,]    1    5    9
  [2,]    2    6   10
  [3,]    3    7   11
  [4,]    4    8   12
    min:
   int [1:4] 1 2 3 4
   int [1:4] 1 2 3 4
   int [1:4] 1 2 3 4
    max:
   int [1:4] 9 10 11 12
   int [1:4] 9 10 11 12
   int [1:4] 9 10 11 12
    range:
   int [1:4, 1:2] 1 2 3 4 9 10 11 12
   int [1:4, 1:2] 1 2 3 4 9 10 11 12
   int [1:4, 1:2] 1 2 3 4 9 10 11 12
  integer w/ NA (integer) w/ na.rm = FALSE:
       [,1] [,2] [,3]
  [1,]   NA   NA   NA
  [2,]   NA   NA   NA
  [3,]   NA   NA   NA
  [4,]   NA   NA   NA
    min:
   int [1:4] NA NA NA NA
   int [1:4] NA NA NA NA
   int [1:4] NA NA NA NA
    max:
   int [1:4] NA NA NA NA
   int [1:4] NA NA NA NA
   int [1:4] NA NA NA NA
    range:
   int [1:4, 1:2] NA NA NA NA NA NA NA NA
   int [1:4, 1:2] NA NA NA NA NA NA NA NA
   int [1:4, 1:2] NA NA NA NA NA NA NA NA
  integer w/ NA (integer) w/ na.rm = FALSE:
       [,1] [,2] [,3]
  [1,]   NA   NA   NA
  [2,]   NA   NA   NA
  [3,]   NA   NA   NA
  [4,]   NA   NA   NA
    min:
   int [1:4] NA NA NA NA
   int [1:4] NA NA NA NA
   int [1:4] NA NA NA NA
    max:
   int [1:4] NA NA NA NA
   int [1:4] NA NA NA NA
   int [1:4] NA NA NA NA
    range:
   int [1:4, 1:2] NA NA NA NA NA NA NA NA
   int [1:4, 1:2] NA NA NA NA NA NA NA NA
   int [1:4, 1:2] NA NA NA NA NA NA NA NA
  real (double) w/ na.rm = FALSE:
       [,1] [,2] [,3]
  [1,]    1    5    9
  [2,]    2    6   10
  [3,]    3    7   11
  [4,]    4    8   12
    min:
   num [1:4] 1 2 3 4
   num [1:4] 1 2 3 4
   num [1:4] 1 2 3 4
    max:
   num [1:4] 9 10 11 12
   num [1:4] 9 10 11 12
   num [1:4] 9 10 11 12
    range:
   num [1:4, 1:2] 1 2 3 4 9 10 11 12
   num [1:4, 1:2] 1 2 3 4 9 10 11 12
   num [1:4, 1:2] 1 2 3 4 9 10 11 12
  real (double) w/ na.rm = FALSE:
       [,1] [,2] [,3]
  [1,]    1    5    9
  [2,]    2    6   10
  [3,]    3    7   11
  [4,]    4    8   12
    min:
   num [1:4] 1 2 3 4
   num [1:4] 1 2 3 4
   num [1:4] 1 2 3 4
    max:
   num [1:4] 9 10 11 12
   num [1:4] 9 10 11 12
   num [1:4] 9 10 11 12
    range:
   num [1:4, 1:2] 1 2 3 4 9 10 11 12
   num [1:4, 1:2] 1 2 3 4 9 10 11 12
   num [1:4, 1:2] 1 2 3 4 9 10 11 12
  real w/ NA (double) w/ na.rm = FALSE:
       [,1] [,2] [,3]
  [1,]   NA   NA   NA
  [2,]   NA   NA   NA
  [3,]   NA   NA   NA
  [4,]   NA   NA   NA
    min:
   num [1:4] NA NA NA NA
   num [1:4] NA NA NA NA
   num [1:4] NA NA NA NA
    max:
   num [1:4] NA NA NA NA
   num [1:4] NA NA NA NA
   num [1:4] NA NA NA NA
    range:
   num [1:4, 1:2] NA NA NA NA NA NA NA NA
   num [1:4, 1:2] NA NA NA NA NA NA NA NA
   num [1:4, 1:2] NA NA NA NA NA NA NA NA
  real w/ NA (double) w/ na.rm = FALSE:
       [,1] [,2] [,3]
  [1,]   NA   NA   NA
  [2,]   NA   NA   NA
  [3,]   NA   NA   NA
  [4,]   NA   NA   NA
    min:
   num [1:4] NA NA NA NA
   num [1:4] NA NA NA NA
   num [1:4] NA NA NA NA
    max:
   num [1:4] NA NA NA NA
   num [1:4] NA NA NA NA
   num [1:4] NA NA NA NA
    range:
   num [1:4, 1:2] NA NA NA NA NA NA NA NA
   num [1:4, 1:2] NA NA NA NA NA NA NA NA
   num [1:4, 1:2] NA NA NA NA NA NA NA NA
  real + NA cell (double) w/ na.rm = FALSE:
       [,1] [,2] [,3]
  [1,]    1    5    9
  [2,]    2   NA   10
  [3,]    3    7   11
  [4,]    4    8   12
    min:
   num [1:4] 1 NA 3 4
   num [1:4] 1 NA 3 4
   num [1:4] 1 NA 3 4
    max:
   num [1:4] 9 NA 11 12
   num [1:4] 9 NA 11 12
   num [1:4] 9 NA 11 12
    range:
   num [1:4, 1:2] 1 NA 3 4 9 NA 11 12
   num [1:4, 1:2] 1 NA 3 4 9 NA 11 12
   num [1:4, 1:2] 1 NA 3 4 9 NA 11 12
  real + NA cell (double) w/ na.rm = FALSE:
       [,1] [,2] [,3]
  [1,]    1    5    9
  [2,]    2   NA   10
  [3,]    3    7   11
  [4,]    4    8   12
    min:
   num [1:4] 1 NA 3 4
   num [1:4] 1 NA 3 4
   num [1:4] 1 NA 3 4
    max:
   num [1:4] 9 NA 11 12
   num [1:4] 9 NA 11 12
   num [1:4] 9 NA 11 12
    range:
   num [1:4, 1:2] 1 NA 3 4 9 NA 11 12
   num [1:4, 1:2] 1 NA 3 4 9 NA 11 12
   num [1:4, 1:2] 1 NA 3 4 9 NA 11 12
  real + NA row (double) w/ na.rm = FALSE:
       [,1] [,2] [,3]
  [1,]    1    5    9
  [2,]   NA   NA   NA
  [3,]    3    7   11
  [4,]    4    8   12
    min:
   num [1:4] 1 NA 3 4
   num [1:4] 1 NA 3 4
   num [1:4] 1 NA 3 4
    max:
   num [1:4] 9 NA 11 12
   num [1:4] 9 NA 11 12
   num [1:4] 9 NA 11 12
    range:
   num [1:4, 1:2] 1 NA 3 4 9 NA 11 12
   num [1:4, 1:2] 1 NA 3 4 9 NA 11 12
   num [1:4, 1:2] 1 NA 3 4 9 NA 11 12
  real + NA row (double) w/ na.rm = FALSE:
       [,1] [,2] [,3]
  [1,]    1    5    9
  [2,]   NA   NA   NA
  [3,]    3    7   11
  [4,]    4    8   12
    min:
   num [1:4] 1 NA 3 4
   num [1:4] 1 NA 3 4
   num [1:4] 1 NA 3 4
    max:
   num [1:4] 9 NA 11 12
   num [1:4] 9 NA 11 12
   num [1:4] 9 NA 11 12
    range:
   num [1:4, 1:2] 1 NA 3 4 9 NA 11 12
   num [1:4, 1:2] 1 NA 3 4 9 NA 11 12
   num [1:4, 1:2] 1 NA 3 4 9 NA 11 12
  real + NaN row (double) w/ na.rm = FALSE:
       [,1] [,2] [,3]
  [1,]    1    5    9
  [2,]  NaN  NaN  NaN
  [3,]    3    7   11
  [4,]    4    8   12
    min:
   num [1:4] 1 NaN 3 4
   num [1:4] 1 NaN 3 4
   num [1:4] 1 NaN 3 4
    max:
   num [1:4] 9 NaN 11 12
   num [1:4] 9 NaN 11 12
   num [1:4] 9 NaN 11 12
    range:
   num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12
   num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12
   num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12
  real + NaN row (double) w/ na.rm = FALSE:
       [,1] [,2] [,3]
  [1,]    1    5    9
  [2,]  NaN  NaN  NaN
  [3,]    3    7   11
  [4,]    4    8   12
    min:
   num [1:4] 1 NaN 3 4
   num [1:4] 1 NaN 3 4
   num [1:4] 1 NaN 3 4
    max:
   num [1:4] 9 NaN 11 12
   num [1:4] 9 NaN 11 12
   num [1:4] 9 NaN 11 12
    range:
   num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12
   num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12
   num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12
  real + Inf cell (double) w/ na.rm = FALSE:
       [,1] [,2] [,3]
  [1,]    1    5    9
  [2,]    2  Inf   10
  [3,]    3    7   11
  [4,]    4    8   12
    min:
   num [1:4] 1 2 3 4
   num [1:4] 1 2 3 4
   num [1:4] 1 2 3 4
    max:
   num [1:4] 9 Inf 11 12
   num [1:4] 9 Inf 11 12
   num [1:4] 9 Inf 11 12
    range:
   num [1:4, 1:2] 1 2 3 4 9 ...
   num [1:4, 1:2] 1 2 3 4 9 ...
   num [1:4, 1:2] 1 2 3 4 9 ...
  real + Inf cell (double) w/ na.rm = FALSE:
       [,1] [,2] [,3]
  [1,]    1    5    9
  [2,]    2  Inf   10
  [3,]    3    7   11
  [4,]    4    8   12
    min:
   num [1:4] 1 2 3 4
   num [1:4] 1 2 3 4
   num [1:4] 1 2 3 4
    max:
   num [1:4] 9 Inf 11 12
   num [1:4] 9 Inf 11 12
   num [1:4] 9 Inf 11 12
    range:
   num [1:4, 1:2] 1 2 3 4 9 ...
   num [1:4, 1:2] 1 2 3 4 9 ...
   num [1:4, 1:2] 1 2 3 4 9 ...
  real + Inf row (double) w/ na.rm = FALSE:
       [,1] [,2] [,3]
  [1,]    1    5    9
  [2,]  Inf  Inf  Inf
  [3,]    3    7   11
  [4,]    4    8   12
    min:
   num [1:4] 1 Inf 3 4
   num [1:4] 1 Inf 3 4
   num [1:4] 1 Inf 3 4
    max:
   num [1:4] 9 Inf 11 12
   num [1:4] 9 Inf 11 12
   num [1:4] 9 Inf 11 12
    range:
   num [1:4, 1:2] 1 Inf 3 4 9 ...
   num [1:4, 1:2] 1 Inf 3 4 9 ...
   num [1:4, 1:2] 1 Inf 3 4 9 ...
  real + Inf row (double) w/ na.rm = FALSE:
       [,1] [,2] [,3]
  [1,]    1    5    9
  [2,]  Inf  Inf  Inf
  [3,]    3    7   11
  [4,]    4    8   12
    min:
   num [1:4] 1 Inf 3 4
   num [1:4] 1 Inf 3 4
   num [1:4] 1 Inf 3 4
    max:
   num [1:4] 9 Inf 11 12
   num [1:4] 9 Inf 11 12
   num [1:4] 9 Inf 11 12
    range:
   num [1:4, 1:2] 1 Inf 3 4 9 ...
   num [1:4, 1:2] 1 Inf 3 4 9 ...
   num [1:4, 1:2] 1 Inf 3 4 9 ...
  real + NaN cell (double) w/ na.rm = FALSE:
       [,1] [,2] [,3]
  [1,]    1    5    9
  [2,]    2  NaN   10
  [3,]    3    7   11
  [4,]    4    8   12
    min:
   num [1:4] 1 NaN 3 4
   num [1:4] 1 NaN 3 4
   num [1:4] 1 NaN 3 4
    max:
   num [1:4] 9 NaN 11 12
   num [1:4] 9 NaN 11 12
   num [1:4] 9 NaN 11 12
    range:
   num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12
   num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12
   num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12
  real + NaN cell (double) w/ na.rm = FALSE:
       [,1] [,2] [,3]
  [1,]    1    5    9
  [2,]    2  NaN   10
  [3,]    3    7   11
  [4,]    4    8   12
    min:
   num [1:4] 1 NaN 3 4
   num [1:4] 1 NaN 3 4
   num [1:4] 1 NaN 3 4
    max:
   num [1:4] 9 NaN 11 12
   num [1:4] 9 NaN 11 12
   num [1:4] 9 NaN 11 12
    range:
   num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12
   num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12
   num [1:4, 1:2] 1 NaN 3 4 9 NaN 11 12
  real w/ NA + NaN cell (double) w/ na.rm = FALSE:
       [,1] [,2] [,3]
  [1,]   NA   NA   NA
  [2,]   NA  NaN   NA
  [3,]   NA   NA   NA
  [4,]   NA   NA   NA
    min:
   num [1:4] NA NA NA NA
   num [1:4] NA NA NA NA
   num [1:4] NA NA NA NA
    max:
   num [1:4] NA NA NA NA
   num [1:4] NA NA NA NA
   num [1:4] NA NA NA NA
    range:
   num [1:4, 1:2] NA NA NA NA NA NA NA NA
   num [1:4, 1:2] NA NA NA NA NA NA NA NA
   num [1:4, 1:2] NA NA NA NA NA NA NA NA
  real w/ NA + NaN cell (double) w/ na.rm = FALSE:
       [,1] [,2] [,3]
  [1,]   NA   NA   NA
  [2,]   NA  NaN   NA
  [3,]   NA   NA   NA
  [4,]   NA   NA   NA
    min:
   num [1:4] NA NA NA NA
   num [1:4] NA NA NA NA
   num [1:4] NA NA NA NA
    max:
   num [1:4] NA NA NA NA
   num [1:4] NA NA NA NA
   num [1:4] NA NA NA NA
    range:
   num [1:4, 1:2] NA NA NA NA NA NA NA NA
   num [1:4, 1:2] NA NA NA NA NA NA NA NA
   num [1:4, 1:2] NA NA NA NA NA NA NA NA
  real w/ NA + NaN row (double) w/ na.rm = FALSE:
       [,1] [,2] [,3]
  [1,]   NA   NA   NA
  [2,]  NaN  NaN  NaN
  [3,]   NA   NA   NA
  [4,]   NA   NA   NA
    min:
   num [1:4] NA NaN NA NA
   num [1:4] NA NaN NA NA
   num [1:4] NA NaN NA NA
    max:
   num [1:4] NA NaN NA NA
   num [1:4] NA NaN NA NA
   num [1:4] NA NaN NA NA
    range:
   num [1:4, 1:2] NA NaN NA NA NA NaN NA NA
   num [1:4, 1:2] NA NaN NA NA NA NaN NA NA
   num [1:4, 1:2] NA NaN NA NA NA NaN NA NA
  real w/ NA + NaN row (double) w/ na.rm = FALSE:
       [,1] [,2] [,3]
  [1,]   NA   NA   NA
  [2,]  NaN  NaN  NaN
  [3,]   NA   NA   NA
  [4,]   NA   NA   NA
    min:
   num [1:4] NA NaN NA NA
   num [1:4] NA NaN NA NA
   num [1:4] NA NaN NA NA
    max:
   num [1:4] NA NaN NA NA
   num [1:4] NA NaN NA NA
   num [1:4] NA NaN NA NA
    range:
   num [1:4, 1:2] NA NaN NA NA NA NaN NA NA
   num [1:4, 1:2] NA NaN NA NA NA NaN NA NA
   num [1:4, 1:2] NA NaN NA NA NA NaN NA NA
  integer (integer) w/ na.rm = TRUE:
       [,1] [,2] [,3]
  [1,]    1    5    9
  [2,]    2    6   10
  [3,]    3    7   11
  [4,]    4    8   12
    min:
   int [1:4] 1 2 3 4
   int [1:4] 1 2 3 4
   int [1:4] 1 2 3 4
    max:
   int [1:4] 9 10 11 12
   int [1:4] 9 10 11 12
   int [1:4] 9 10 11 12
    range:
   int [1:4, 1:2] 1 2 3 4 9 10 11 12
   int [1:4, 1:2] 1 2 3 4 9 10 11 12
   int [1:4, 1:2] 1 2 3 4 9 10 11 12
  integer (integer) w/ na.rm = TRUE:
       [,1] [,2] [,3]
  [1,]    1    5    9
  [2,]    2    6   10
  [3,]    3    7   11
  [4,]    4    8   12
    min:
   int [1:4] 1 2 3 4
   int [1:4] 1 2 3 4
   int [1:4] 1 2 3 4
    max:
   int [1:4] 9 10 11 12
   int [1:4] 9 10 11 12
   int [1:4] 9 10 11 12
    range:
   int [1:4, 1:2] 1 2 3 4 9 10 11 12
   int [1:4, 1:2] 1 2 3 4 9 10 11 12
   int [1:4, 1:2] 1 2 3 4 9 10 11 12
  integer w/ NA (integer) w/ na.rm = TRUE:
       [,1] [,2] [,3]
  [1,]   NA   NA   NA
  [2,]   NA   NA   NA
  [3,]   NA   NA   NA
  [4,]   NA   NA   NA
    min:
   num [1:4] Inf Inf Inf Inf
   num [1:4] Inf Inf Inf Inf
   num [1:4] Inf Inf Inf Inf
    max:
   num [1:4] -Inf -Inf -Inf -Inf
   num [1:4] -Inf -Inf -Inf -Inf
   num [1:4] -Inf -Inf -Inf -Inf
    range:
   num [1:4, 1:2] Inf Inf Inf Inf -Inf ...
   num [1:4, 1:2] Inf Inf Inf Inf -Inf ...
   num [1:4, 1:2] Inf Inf Inf Inf -Inf ...
  integer w/ NA (integer) w/ na.rm = TRUE:
       [,1] [,2] [,3]
  [1,]   NA   NA   NA
  [2,]   NA   NA   NA
  [3,]   NA   NA   NA
  [4,]   NA   NA   NA
    min:
   num [1:4] Inf Inf Inf Inf
   num [1:4] Inf Inf Inf Inf
   num [1:4] Inf Inf Inf Inf
    max:
   num [1:4] -Inf -Inf -Inf -Inf
   num [1:4] -Inf -Inf -Inf -Inf
   num [1:4] -Inf -Inf -Inf -Inf
    range:
   num [1:4, 1:2] Inf Inf Inf Inf -Inf ...
   num [1:4, 1:2] Inf Inf Inf Inf -Inf ...
   num [1:4, 1:2] Inf Inf Inf Inf -Inf ...
  real (double) w/ na.rm = TRUE:
       [,1] [,2] [,3]
  [1,]    1    5    9
  [2,]    2    6   10
  [3,]    3    7   11
  [4,]    4    8   12
    min:
   num [1:4] 1 2 3 4
   num [1:4] 1 2 3 4
   num [1:4] 1 2 3 4
    max:
   num [1:4] 9 10 11 12
   num [1:4] 9 10 11 12
   num [1:4] 9 10 11 12
    range:
   num [1:4, 1:2] 1 2 3 4 9 10 11 12
   num [1:4, 1:2] 1 2 3 4 9 10 11 12
   num [1:4, 1:2] 1 2 3 4 9 10 11 12
  real (double) w/ na.rm = TRUE:
       [,1] [,2] [,3]
  [1,]    1    5    9
  [2,]    2    6   10
  [3,]    3    7   11
  [4,]    4    8   12
    min:
   num [1:4] 1 2 3 4
   num [1:4] 1 2 3 4
   num [1:4] 1 2 3 4
    max:
   num [1:4] 9 10 11 12
   num [1:4] 9 10 11 12
   num [1:4] 9 10 11 12
    range:
   num [1:4, 1:2] 1 2 3 4 9 10 11 12
   num [1:4, 1:2] 1 2 3 4 9 10 11 12
   num [1:4, 1:2] 1 2 3 4 9 10 11 12
  real w/ NA (double) w/ na.rm = TRUE:
       [,1] [,2] [,3]
  [1,]   NA   NA   NA
  [2,]   NA   NA   NA
  [3,]   NA   NA   NA
  [4,]   NA   NA   NA
    min:
   num [1:4] Inf Inf Inf Inf
   num [1:4] Inf Inf Inf Inf
   num [1:4] Inf Inf Inf Inf
    max:
   num [1:4] -Inf -Inf -Inf -Inf
   num [1:4] -Inf -Inf -Inf -Inf
   num [1:4] -Inf -Inf -Inf -Inf
    range:
   num [1:4, 1:2] Inf Inf Inf Inf -Inf ...
   num [1:4, 1:2] Inf Inf Inf Inf -Inf ...
   num [1:4, 1:2] Inf Inf Inf Inf -Inf ...
  real w/ NA (double) w/ na.rm = TRUE:
       [,1] [,2] [,3]
  [1,]   NA   NA   NA
  [2,]   NA   NA   NA
  [3,]   NA   NA   NA
  [4,]   NA   NA   NA
    min:
   num [1:4] Inf Inf Inf Inf
   num [1:4] Inf Inf Inf Inf
   num [1:4] Inf Inf Inf Inf
    max:
   num [1:4] -Inf -Inf -Inf -Inf
   num [1:4] -Inf -Inf -Inf -Inf
   num [1:4] -Inf -Inf -Inf -Inf
    range:
   num [1:4, 1:2] Inf Inf Inf Inf -Inf ...
   num [1:4, 1:2] Inf Inf Inf Inf -Inf ...
   num [1:4, 1:2] Inf Inf Inf Inf -Inf ...
  real + NA cell (double) w/ na.rm = TRUE:
       [,1] [,2] [,3]
  [1,]    1    5    9
  [2,]    2   NA   10
  [3,]    3    7   11
  [4,]    4    8   12
    min:
   num [1:4] 1 2 3 4
   num [1:4] 1 2 3 4
   num [1:4] 1 2 3 4
    max:
   num [1:4] 9 10 11 12
   num [1:4] 9 10 11 12
   num [1:4] 9 10 11 12
    range:
   num [1:4, 1:2] 1 2 3 4 9 10 11 12
   num [1:4, 1:2] 1 2 3 4 9 10 11 12
   num [1:4, 1:2] 1 2 3 4 9 10 11 12
  real + NA cell (double) w/ na.rm = TRUE:
       [,1] [,2] [,3]
  [1,]    1    5    9
  [2,]    2   NA   10
  [3,]    3    7   11
  [4,]    4    8   12
    min:
   num [1:4] 1 2 3 4
   num [1:4] 1 2 3 4
   num [1:4] 1 2 3 4
    max:
   num [1:4] 9 10 11 12
   num [1:4] 9 10 11 12
   num [1:4] 9 10 11 12
    range:
   num [1:4, 1:2] 1 2 3 4 9 10 11 12
   num [1:4, 1:2] 1 2 3 4 9 10 11 12
   num [1:4, 1:2] 1 2 3 4 9 10 11 12
  real + NA row (double) w/ na.rm = TRUE:
       [,1] [,2] [,3]
  [1,]    1    5    9
  [2,]   NA   NA   NA
  [3,]    3    7   11
  [4,]    4    8   12
    min:
   num [1:4] 1 Inf 3 4
   num [1:4] 1 Inf 3 4
   num [1:4] 1 Inf 3 4
    max:
   num [1:4] 9 -Inf 11 12
   num [1:4] 9 -Inf 11 12
   num [1:4] 9 -Inf 11 12
    range:
   num [1:4, 1:2] 1 Inf 3 4 9 ...
   num [1:4, 1:2] 1 Inf 3 4 9 ...
   num [1:4, 1:2] 1 Inf 3 4 9 ...
  real + NA row (double) w/ na.rm = TRUE:
       [,1] [,2] [,3]
  [1,]    1    5    9
  [2,]   NA   NA   NA
  [3,]    3    7   11
  [4,]    4    8   12
    min:
   num [1:4] 1 Inf 3 4
   num [1:4] 1 Inf 3 4
   num [1:4] 1 Inf 3 4
    max:
   num [1:4] 9 -Inf 11 12
   num [1:4] 9 -Inf 11 12
   num [1:4] 9 -Inf 11 12
    range:
   num [1:4, 1:2] 1 Inf 3 4 9 ...
   num [1:4, 1:2] 1 Inf 3 4 9 ...
   num [1:4, 1:2] 1 Inf 3 4 9 ...
  real + NaN row (double) w/ na.rm = TRUE:
       [,1] [,2] [,3]
  [1,]    1    5    9
  [2,]  NaN  NaN  NaN
  [3,]    3    7   11
  [4,]    4    8   12
    min:
   num [1:4] 1 Inf 3 4
   num [1:4] 1 Inf 3 4
   num [1:4] 1 Inf 3 4
    max:
   num [1:4] 9 -Inf 11 12
   num [1:4] 9 -Inf 11 12
   num [1:4] 9 -Inf 11 12
    range:
   num [1:4, 1:2] 1 Inf 3 4 9 ...
   num [1:4, 1:2] 1 Inf 3 4 9 ...
   num [1:4, 1:2] 1 Inf 3 4 9 ...
  real + NaN row (double) w/ na.rm = TRUE:
       [,1] [,2] [,3]
  [1,]    1    5    9
  [2,]  NaN  NaN  NaN
  [3,]    3    7   11
  [4,]    4    8   12
    min:
   num [1:4] 1 Inf 3 4
   num [1:4] 1 Inf 3 4
   num [1:4] 1 Inf 3 4
    max:
   num [1:4] 9 -Inf 11 12
   num [1:4] 9 -Inf 11 12
   num [1:4] 9 -Inf 11 12
    range:
   num [1:4, 1:2] 1 Inf 3 4 9 ...
   num [1:4, 1:2] 1 Inf 3 4 9 ...
   num [1:4, 1:2] 1 Inf 3 4 9 ...
  real + Inf cell (double) w/ na.rm = TRUE:
       [,1] [,2] [,3]
  [1,]    1    5    9
  [2,]    2  Inf   10
  [3,]    3    7   11
  [4,]    4    8   12
    min:
   num [1:4] 1 2 3 4
   num [1:4] 1 2 3 4
   num [1:4] 1 2 3 4
    max:
   num [1:4] 9 Inf 11 12
   num [1:4] 9 Inf 11 12
   num [1:4] 9 Inf 11 12
    range:
   num [1:4, 1:2] 1 2 3 4 9 ...
   num [1:4, 1:2] 1 2 3 4 9 ...
   num [1:4, 1:2] 1 2 3 4 9 ...
  real + Inf cell (double) w/ na.rm = TRUE:
       [,1] [,2] [,3]
  [1,]    1    5    9
  [2,]    2  Inf   10
  [3,]    3    7   11
  [4,]    4    8   12
    min:
   num [1:4] 1 2 3 4
   num [1:4] 1 2 3 4
   num [1:4] 1 2 3 4
    max:
   num [1:4] 9 Inf 11 12
   num [1:4] 9 Inf 11 12
   num [1:4] 9 Inf 11 12
    range:
   num [1:4, 1:2] 1 2 3 4 9 ...
   num [1:4, 1:2] 1 2 3 4 9 ...
   num [1:4, 1:2] 1 2 3 4 9 ...
  real + Inf row (double) w/ na.rm = TRUE:
       [,1] [,2] [,3]
  [1,]    1    5    9
  [2,]  Inf  Inf  Inf
  [3,]    3    7   11
  [4,]    4    8   12
    min:
   num [1:4] 1 Inf 3 4
   num [1:4] 1 Inf 3 4
   num [1:4] 1 Inf 3 4
    max:
   num [1:4] 9 Inf 11 12
   num [1:4] 9 Inf 11 12
   num [1:4] 9 Inf 11 12
    range:
   num [1:4, 1:2] 1 Inf 3 4 9 ...
   num [1:4, 1:2] 1 Inf 3 4 9 ...
   num [1:4, 1:2] 1 Inf 3 4 9 ...
  real + Inf row (double) w/ na.rm = TRUE:
       [,1] [,2] [,3]
  [1,]    1    5    9
  [2,]  Inf  Inf  Inf
  [3,]    3    7   11
  [4,]    4    8   12
    min:
   num [1:4] 1 Inf 3 4
   num [1:4] 1 Inf 3 4
   num [1:4] 1 Inf 3 4
    max:
   num [1:4] 9 Inf 11 12
   num [1:4] 9 Inf 11 12
   num [1:4] 9 Inf 11 12
    range:
   num [1:4, 1:2] 1 Inf 3 4 9 ...
   num [1:4, 1:2] 1 Inf 3 4 9 ...
   num [1:4, 1:2] 1 Inf 3 4 9 ...
  real + NaN cell (double) w/ na.rm = TRUE:
       [,1] [,2] [,3]
  [1,]    1    5    9
  [2,]    2  NaN   10
  [3,]    3    7   11
  [4,]    4    8   12
    min:
   num [1:4] 1 2 3 4
   num [1:4] 1 2 3 4
   num [1:4] 1 2 3 4
    max:
   num [1:4] 9 10 11 12
   num [1:4] 9 10 11 12
   num [1:4] 9 10 11 12
    range:
   num [1:4, 1:2] 1 2 3 4 9 10 11 12
   num [1:4, 1:2] 1 2 3 4 9 10 11 12
   num [1:4, 1:2] 1 2 3 4 9 10 11 12
  real + NaN cell (double) w/ na.rm = TRUE:
       [,1] [,2] [,3]
  [1,]    1    5    9
  [2,]    2  NaN   10
  [3,]    3    7   11
  [4,]    4    8   12
    min:
   num [1:4] 1 2 3 4
   num [1:4] 1 2 3 4
   num [1:4] 1 2 3 4
    max:
   num [1:4] 9 10 11 12
   num [1:4] 9 10 11 12
   num [1:4] 9 10 11 12
    range:
   num [1:4, 1:2] 1 2 3 4 9 10 11 12
   num [1:4, 1:2] 1 2 3 4 9 10 11 12
   num [1:4, 1:2] 1 2 3 4 9 10 11 12
  real w/ NA + NaN cell (double) w/ na.rm = TRUE:
       [,1] [,2] [,3]
  [1,]   NA   NA   NA
  [2,]   NA  NaN   NA
  [3,]   NA   NA   NA
  [4,]   NA   NA   NA
    min:
   num [1:4] Inf Inf Inf Inf
   num [1:4] Inf Inf Inf Inf
   num [1:4] Inf Inf Inf Inf
    max:
   num [1:4] -Inf -Inf -Inf -Inf
   num [1:4] -Inf -Inf -Inf -Inf
   num [1:4] -Inf -Inf -Inf -Inf
    range:
   num [1:4, 1:2] Inf Inf Inf Inf -Inf ...
   num [1:4, 1:2] Inf Inf Inf Inf -Inf ...
   num [1:4, 1:2] Inf Inf Inf Inf -Inf ...
  real w/ NA + NaN cell (double) w/ na.rm = TRUE:
       [,1] [,2] [,3]
  [1,]   NA   NA   NA
  [2,]   NA  NaN   NA
  [3,]   NA   NA   NA
  [4,]   NA   NA   NA
    min:
   num [1:4] Inf Inf Inf Inf
   num [1:4] Inf Inf Inf Inf
   num [1:4] Inf Inf Inf Inf
    max:
   num [1:4] -Inf -Inf -Inf -Inf
   num [1:4] -Inf -Inf -Inf -Inf
   num [1:4] -Inf -Inf -Inf -Inf
    range:
   num [1:4, 1:2] Inf Inf Inf Inf -Inf ...
   num [1:4, 1:2] Inf Inf Inf Inf -Inf ...
   num [1:4, 1:2] Inf Inf Inf Inf -Inf ...
  real w/ NA + NaN row (double) w/ na.rm = TRUE:
       [,1] [,2] [,3]
  [1,]   NA   NA   NA
  [2,]  NaN  NaN  NaN
  [3,]   NA   NA   NA
  [4,]   NA   NA   NA
    min:
   num [1:4] Inf Inf Inf Inf
   num [1:4] Inf Inf Inf Inf
   num [1:4] Inf Inf Inf Inf
    max:
   num [1:4] -Inf -Inf -Inf -Inf
   num [1:4] -Inf -Inf -Inf -Inf
   num [1:4] -Inf -Inf -Inf -Inf
    range:
   num [1:4, 1:2] Inf Inf Inf Inf -Inf ...
   num [1:4, 1:2] Inf Inf Inf Inf -Inf ...
   num [1:4, 1:2] Inf Inf Inf Inf -Inf ...
  real w/ NA + NaN row (double) w/ na.rm = TRUE:
       [,1] [,2] [,3]
  [1,]   NA   NA   NA
  [2,]  NaN  NaN  NaN
  [3,]   NA   NA   NA
  [4,]   NA   NA   NA
    min:
   num [1:4] Inf Inf Inf Inf
   num [1:4] Inf Inf Inf Inf
   num [1:4] Inf Inf Inf Inf
    max:
   num [1:4] -Inf -Inf -Inf -Inf
   num [1:4] -Inf -Inf -Inf -Inf
   num [1:4] -Inf -Inf -Inf -Inf
    range:
   num [1:4, 1:2] Inf Inf Inf Inf -Inf ...
   num [1:4, 1:2] Inf Inf Inf Inf -Inf ...
   num [1:4, 1:2] Inf Inf Inf Inf -Inf ...
  > 
  > proc.time()
     user  system elapsed 
     0.92    0.09    1.00 
Running the tests in 'tests/rowRanges_subset.R' failed.
Complete output:
  > library("matrixStats")
  > 
  > rowMins_R <- function(x, ..., useNames = NA) {
  +   suppressWarnings({
  +     res <- apply(x, MARGIN = 1L, FUN = min, ...)
  +   })
  +   if (is.na(useNames) || !useNames) names(res) <- NULL
  +   res
  + } # rowMins_R()
  > 
  > rowMaxs_R <- function(x, ..., useNames = NA) {
  +   suppressWarnings({
  +     res <- apply(x, MARGIN = 1L, FUN = max, ...)
  +   })
  +   if (is.na(useNames) || !useNames) names(res) <- NULL
  +   res
  + } # rowMaxs_R()
  > 
  > rowRanges_R <- function(x, ..., useNames = NA) {
  +   suppressWarnings({
  +     ans <- t(apply(x, MARGIN = 1L, FUN = range, ...))
  +   })
  + 
  +   # Preserve rownames attribute
  +   dim <- c(dim(x)[1], 2L)
  +   if (!isTRUE(all.equal(dim(ans), dim))) {
  +     dim(ans) <- dim
  +     rownames <- rownames(x)
  +     if (!is.null(dimnames)) rownames(ans) <- rownames
  +   }
  +   if (is.na(useNames) || !useNames) dimnames(ans) <- NULL
  +   ans
  + } # rowRanges_R()
  > 
  > 
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > # Subsetted tests
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > source("utils/validateIndicesFramework.R")
  > x <- matrix(runif(6 * 6, min = -6, max = 6), nrow = 6, ncol = 6)
  > storage.mode(x) <- "integer"
  > 
  > # To check rownames/names attributes
  > dimnames <- list(letters[1:6], LETTERS[1:6])
  > 
  > # Test with and without dimnames on x
  > for (setDimnames in c(TRUE, FALSE)) {
  +   if (setDimnames) dimnames(x) <- dimnames
  +   else dimnames(x) <- NULL
  +   
  +   count <- 0L
  +   for (rows in index_cases) {
  +     for (cols in index_cases) {
  +       count <- count + 1L
  +       na.rm <- c(TRUE, FALSE)[count %% 2 + 1]
  +       useNames <- c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)
  +       useNames <- useNames[count %% length(useNames) + 1]
  + 
  +       validateIndicesTestMatrix(x, rows, cols,
  +                                 ftest = rowRanges, fsure = rowRanges_R,
  +                                 na.rm = na.rm, useNames = useNames)
  +       validateIndicesTestMatrix(x, rows, cols,
  +                                 ftest = rowMins, fsure = rowMins_R,
  +                                 na.rm = na.rm, useNames = useNames)
  +       validateIndicesTestMatrix(x, rows, cols,
  +                                 ftest = rowMaxs, fsure = rowMaxs_R,
  +                                 na.rm = na.rm, useNames = useNames)
  + 
  +       validateIndicesTestMatrix(x, rows, cols,
  +                                 fcoltest = colRanges, fsure = rowRanges_R,
  +                                 na.rm = na.rm, useNames = useNames)
  +       validateIndicesTestMatrix(x, rows, cols,
  +                                 fcoltest = colMins, fsure = rowMins_R,
  +                                 na.rm = na.rm, useNames = useNames)
  +       validateIndicesTestMatrix(x, rows, cols,
  +                                 fcoltest = colMaxs, fsure = rowMaxs_R,
  +                                 na.rm = na.rm, useNames = useNames)
  +     }
  +   }
  + }
  > 
  > proc.time()
     user  system elapsed 
     2.04    0.07    2.11 
Running the tests in 'tests/rowRanks.R' failed.
Complete output:
  > library("matrixStats")
  > 
  > dense_rank <- function(x) match(x, table = sort(unique(x)))
  > 
  > rowRanks_R <- function(x, ties.method, ..., useNames = NA) {
  +   if (ties.method == "dense") {
  +     res <- t(apply(x, MARGIN = 1L, FUN = dense_rank))
  +   } else {
  +     res <- t(apply(x, MARGIN = 1L, FUN = rank, na.last = "keep", ties.method = ties.method))
  +   }
  +   
  +   # Preserve dimnames attribute?
  +   dim(res) <- dim(x)
  +   dimnames(res) <- if (isTRUE(useNames)) dimnames(x) else NULL
  +   
  +   res
  + }
  > 
  > colRanks_R <- function(x, ties.method, preserveShape = FALSE, ..., useNames = NA) {
  +   if (ties.method == "dense") {
  +     res <- t(apply(x, MARGIN = 2L, FUN = dense_rank))
  +   } else {
  +     res <- t(apply(x, MARGIN = 2L, FUN = rank, na.last = "keep", ties.method = ties.method))
  +   }
  +   
  +   # Preserve dimnames attribute?
  +   tx <- t(x)
  +   dim(res) <- dim(tx)
  +   dimnames(res) <- if (isTRUE(useNames)) dimnames(tx) else NULL
  +   
  +   if (preserveShape) res <- t(res)
  +   res
  + }
  > 
  > set.seed(1)
  > 
  > cat("Consistency checks:\n")
  Consistency checks:
  > xs <- vector("list", length = 4L)
  > for (kk in 1:4) {
  +   
  +   # Simulate data in a matrix of any shape
  +   dim <- sample(40:80, size = 2L)
  +   n <- prod(dim)
  +   x <- rnorm(n, sd = 10)
  +   dim(x) <- dim
  +   
  +   # Add NAs?
  +   if ((kk %% 4) %in% c(3, 0)) {
  +     cat("Adding NAs\n")
  +     nna <- sample(n, size = 1L)
  +     x[sample(length(x), size = nna)] <- NA_real_
  +   }
  +   
  +   # Integer or double?
  +   if ((kk %% 4) %in% c(2, 0)) {
  +     cat("Coercing to integers\n")
  +     storage.mode(x) <- "integer"
  +   }
  + 
  +   xs[[kk]] <- x
  + } # for (kk ...)
  Coercing to integers
  Adding NAs
  Adding NAs
  Coercing to integers
  > str(xs)
  List of 4
   $ : num [1:43, 1:78] 13.3 12.72 4.15 -15.4 -9.29 ...
   $ : int [1:46, 1:61] 2 11 -16 -5 19 5 26 -13 1 -9 ...
   $ : num [1:42, 1:47] NA -22.3 NA NA NA ...
   $ : int [1:42, 1:78] NA NA NA NA NA NA NA NA NA NA ...
  > 
  > for (kk in 1:4) {
  +   cat("Random test #", kk, "\n", sep = "")
  +   x <- xs[[kk]]
  +   tx <- t(x)
  +   
  +   for (ties in c("max", "min", "average", "first", "last", "dense")) {
  +     cat(sprintf("ties.method = %s\n", ties))
  +     # rowRanks():
  +     y1 <- matrixStats::rowRanks(x, ties.method = ties)
  +     if (ties != "last" || getRversion() >= "3.3.0") {
  +       y2 <- rowRanks_R(x, ties.method = ties)
  +       stopifnot(identical(y1, y2))
  +     }
  +     
  +     y3 <- matrixStats::colRanks(tx, ties.method = ties)
  +     stopifnot(identical(y1, y3))
  +     
  +     # colRanks():
  +     y1 <- matrixStats::colRanks(x, ties.method = ties)
  +     if (ties != "last" || getRversion() >= "3.3.0") {
  +       y2 <- colRanks_R(x, ties.method = ties)
  +       stopifnot(identical(y1, y2))
  +     }
  +     
  +     y3 <- matrixStats::rowRanks(tx, ties.method = ties)
  +     stopifnot(identical(y1, y3))
  +   }
  + } # for (kk ...)
  Random test #1
  ties.method = max
  ties.method = min
  ties.method = average
  ties.method = first
  ties.method = last
  ties.method = dense
  Random test #2
  ties.method = max
  ties.method = min
  ties.method = average
  ties.method = first
  ties.method = last
  ties.method = dense
  Random test #3
  ties.method = max
  ties.method = min
  ties.method = average
  ties.method = first
  ties.method = last
  ties.method = dense
  Random test #4
  ties.method = max
  ties.method = min
  ties.method = average
  ties.method = first
  ties.method = last
  ties.method = dense
  > 
  > # Note, below we know ties.method %in% c("min", "max", "average") is correct
  > 
  > cat("Consistency checks for random:\n")
  Consistency checks for random:
  > tolerance <- 0.1
  > nsamples <- 10000
  > for (kk in 1:4) {
  +   cat("Random test #", kk, "\n", sep = "")
  +   x <- xs[[kk]]
  +   tx <- t(x)
  + 
  +   for (ties in c("random")) {
  +     cat(sprintf("ties.method = %s\n", ties))
  +     
  +     ## rowRanks():
  +     y0 <- rowRanks_R(x, ties.method = ties)
  +     y1 <- matrixStats::rowRanks(x, ties.method = ties)
  +     
  +     ## Assert symmetric rank differences
  +     d <- y1 - y0
  +     stopifnot(all(rowSums(d) == 0, na.rm = TRUE))
  +     
  +     ## Assert within [min, max]
  +     y2min <- matrixStats::rowRanks(x, ties.method = "min")
  +     y2max <- matrixStats::rowRanks(x, ties.method = "max")
  +     stopifnot(all(y1 >= y2min, na.rm = TRUE) && all(y1 <= y2max, na.rm = TRUE))
  +     ## Assert near average
  +     y1list <- replicate(nsamples, matrixStats::rowRanks(x, ties.method = ties), simplify = FALSE)
  +     y1mean <- Reduce(`+`, y1list) / nsamples
  +     y2avg <- matrixStats::rowRanks(x, ties.method = "average")
  +     stopifnot(all(abs(y1mean - y2avg) < tolerance, na.rm = TRUE))
  + 
  +     ## colRanks():
  +     y0 <- colRanks_R(x, ties.method = ties)
  +     y1 <- matrixStats::colRanks(x, ties.method = ties)
  + 
  +     ## Assert symmetric rank differences
  +     d <- y1 - y0
  +     stopifnot(all(rowSums(d) == 0, na.rm = TRUE))
  + 
  +     ## Assert within [min, max]
  +     y2min <- matrixStats::colRanks(x, ties.method = "min")
  +     y2max <- matrixStats::colRanks(x, ties.method = "max")
  +     stopifnot(all(y1 >= y2min, na.rm = TRUE) && all(y1 <= y2max, na.rm = TRUE))
  +     y1list <- replicate(nsamples, matrixStats::colRanks(x, ties.method = ties), simplify = FALSE)
  +     y1mean <- Reduce(`+`, y1list) / nsamples
  +     ## Assert near average
  +     y2avg <- matrixStats::colRanks(x, ties.method = "average")
  +     stopifnot(all(abs(y1mean - y2avg) < tolerance, na.rm = TRUE))
  +   }
  + } # for (kk ...)
  Random test #1
  ties.method = random
  Random test #2
  ties.method = random
  Random test #3
  ties.method = random
  Random test #4
  ties.method = random
  > 
  > 
  > ## Exception handling
  > x <- matrix(1:12, nrow = 3L, ncol = 4L)
  > y <- try(rowRanks(x, ties.method = "unknown"), silent = TRUE)
  > stopifnot(inherits(y, "try-error"))
  > 
  > y <- try(colRanks(x, ties.method = "unknown"), silent = TRUE)
  > stopifnot(inherits(y, "try-error"))
  > 
  > dimnames <- list(letters[1:3], LETTERS[1:4])
  > for (mode in c("integer", "double")){
  +   storage.mode(x) <- mode
  +   # Test with and without dimnames on x
  +   for (setDimnames in c(TRUE, FALSE)) {
  +     if (setDimnames) dimnames(x) <- dimnames
  +     else dimnames(x) <- NULL
  +     # Check names attribute
  +     for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) {
  +       for (ties in c("max", "min", "average", "first", "last", "dense", "random")) {
  +         cat(sprintf("ties.method = %s\n", ties))
  +         # rowRanks():
  +         y1 <- matrixStats::rowRanks(x, ties.method = ties, useNames = useNames)
  +         if (ties != "last" || getRversion() >= "3.3.0") {
  +           y2 <- rowRanks_R(x, ties.method = ties, useNames = useNames)
  +           stopifnot(identical(y1, y2))
  +         }
  +         
  +         y3 <- matrixStats::colRanks(t(x), ties.method = ties, useNames = useNames)
  +         stopifnot(identical(y1, y3))
  +         
  +         # colRanks():
  +         y1 <- matrixStats::colRanks(x, ties.method = ties, useNames = useNames)
  +         if (ties != "last" || getRversion() >= "3.3.0") {
  +           y2 <- colRanks_R(x, ties.method = ties, useNames = useNames)
  +           stopifnot(identical(y1, y2))
  +         }
  +         
  +         y3 <- matrixStats::rowRanks(t(x), ties.method = ties, useNames = useNames)
  +         stopifnot(identical(y1, y3))
  +         
  +         # Check preserveShape
  +         y1 <- matrixStats::colRanks(x, ties.method = ties, preserveShape = TRUE, useNames = useNames)
  +         if (ties != "last" || getRversion() >= "3.3.0") {
  +           y2 <- colRanks_R(x, ties.method = ties, preserveShape = TRUE, useNames = useNames)
  +           stopifnot(identical(y1, y2))
  +         }
  +       }
  +     }
  +   }
  + }
  ties.method = max
  ties.method = min
  ties.method = average
  ties.method = first
  ties.method = last
  ties.method = dense
  ties.method = random
  ties.method = max
  ties.method = min
  ties.method = average
  ties.method = first
  ties.method = last
  ties.method = dense
  ties.method = random
  ties.method = max
  ties.method = min
  ties.method = average
  ties.method = first
  ties.method = last
  ties.method = dense
  ties.method = random
  ties.method = max
  ties.method = min
  ties.method = average
  ties.method = first
  ties.method = last
  ties.method = dense
  ties.method = random
  ties.method = max
  ties.method = min
  ties.method = average
  ties.method = first
  ties.method = last
  ties.method = dense
  ties.method = random
  ties.method = max
  ties.method = min
  ties.method = average
  ties.method = first
  ties.method = last
  ties.method = dense
  ties.method = random
  ties.method = max
  ties.method = min
  ties.method = average
  ties.method = first
  ties.method = last
  ties.method = dense
  ties.method = random
  ties.method = max
  ties.method = min
  ties.method = average
  ties.method = first
  ties.method = last
  ties.method = dense
  ties.method = random
  > 
  > proc.time()
     user  system elapsed 
     6.09    1.20    7.28 
Running the tests in 'tests/rowSds.R' failed.
Complete output:
  > library("matrixStats")
  > 
  > ## Always allow testing of the 'center' argument (as long as it's not defunct)
  > options(matrixStats.center.onUse = "ignore")
  > 
  > ## Create isFALSE() if running on an old version of R
  > if (!exists("isFALSE", mode="function")) {
  +   isFALSE <- function(x) is.logical(x) && length(x) == 1L && !is.na(x) && !x
  + }
  > 
  > rowSds_R <- function(x, na.rm = FALSE, center = NULL, ..., useNames = NA) {
  +   suppressWarnings({
  +     sigma <- apply(x, MARGIN = 1L, FUN = sd, na.rm = na.rm)
  +   })
  +   stopifnot(!any(is.infinite(sigma)))
  +   
  +   # Keep naming support consistency same as rowSds()
  +   if (is.null(center) || ncol(x) <= 1L) {
  +     if (is.na(useNames) || isFALSE(useNames)) names(sigma) <- NULL
  +   }
  +   else if (isFALSE(useNames)) names(sigma) <- NULL
  +   sigma
  + }
  > 
  > colSds_R <- function(x, na.rm = FALSE, center = NULL, ..., useNames = NA) {
  +   suppressWarnings({
  +     sigma <- apply(x, MARGIN = 2L, FUN = sd, na.rm = na.rm)
  +   })
  +   stopifnot(!any(is.infinite(sigma)))
  +   
  +   # Keep naming support consistency same as colSds()
  +   if (is.null(center) || nrow(x) <= 1L) {
  +     if (is.na(useNames) || isFALSE(useNames)) names(sigma) <- NULL
  +   }
  +   if (isFALSE(useNames)) names(sigma) <- NULL
  +   sigma
  + }
  > 
  > 
  > rowSds_center <- function(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = NA) {
  +   center <- rowWeightedMeans(x, cols = cols, na.rm = na.rm, useNames = FALSE)
  +   sigma <- rowSds(x, rows = rows, cols = cols, center = center, na.rm = na.rm, useNames = useNames)
  +   stopifnot(!any(is.infinite(sigma)))
  +   sigma
  + }
  > 
  > colSds_center <- function(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = NA) {
  +   center <- colWeightedMeans(x, rows = rows, na.rm = na.rm, useNames = FALSE)
  +   sigma <- colSds(x, rows = rows, cols = cols, center = center, na.rm = na.rm, useNames = useNames)
  +   stopifnot(!any(is.infinite(sigma)))
  +   sigma
  + }
  > 
  > 
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > # With and without some NAs
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > for (mode in c("integer", "double")) {
  +   for (add_na in c(FALSE, TRUE)) {
  +     cat("add_na = ", add_na, "\n", sep = "")
  + 
  +     x <- matrix(1:50 + 0.1, nrow = 10L, ncol = 5L)
  +     if (add_na) {
  +       x[3:7, c(2, 4)] <- NA_real_
  +     }
  +     cat("mode: ", mode, "\n", sep = "")
  +     storage.mode(x) <- mode
  +     str(x)
  +     
  +     # To check names attribute
  +     dimnames <- list(letters[1:10], LETTERS[1:5])
  +     
  +     # Test with and without dimnames on x
  +     for (setDimnames in c(TRUE, FALSE)) {
  +       if (setDimnames) dimnames(x) <- dimnames
  +       else dimnames(x) <- NULL
  +       # Row/column ranges
  +       for (na.rm in c(FALSE, TRUE)) {
  +         # Check names attribute
  +         for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) {
  +           r0 <- rowSds_R(x, na.rm = na.rm, useNames = useNames)
  +           r1 <- rowSds(x, na.rm = na.rm, useNames = useNames)
  +           r1b <- rowSds_center(x, na.rm = na.rm, useNames = useNames)
  +           r2 <- colSds(t(x), na.rm = na.rm, useNames = useNames)
  +           r2b <- colSds_center(t(x), na.rm = na.rm, useNames = useNames)
  +           stopifnot(all.equal(r1, r2))
  +           stopifnot(all.equal(r1, r0))
  +           stopifnot(all.equal(r2, r0))
  +           stopifnot(all.equal(r1b, r2b))
  +           stopifnot(
  +             !any(is.infinite(r1)),
  +             !any(is.infinite(r2)),
  +             !any(is.infinite(r1b)),
  +             !any(is.infinite(r2b))
  +           )
  +         }
  +       }
  +     }
  +   } # for (add_na ...)
  + }
  add_na = FALSE
  mode: integer
   int [1:10, 1:5] 1 2 3 4 5 6 7 8 9 10 ...
  add_na = TRUE
  mode: integer
   int [1:10, 1:5] 1 2 3 4 5 6 7 8 9 10 ...
  add_na = FALSE
  mode: double
   num [1:10, 1:5] 1.1 2.1 3.1 4.1 5.1 6.1 7.1 8.1 9.1 10.1 ...
  add_na = TRUE
  mode: double
   num [1:10, 1:5] 1.1 2.1 3.1 4.1 5.1 6.1 7.1 8.1 9.1 10.1 ...
  > 
  > 
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > # All NAs
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > for (mode in c("integer", "double")) {
  +   x <- matrix(NA_real_, nrow = 10L, ncol = 5L)
  +   cat("mode: ", mode, "\n", sep = "")
  +   storage.mode(x) <- mode
  +   str(x)
  +   
  +   # Test with and without dimnames on x
  +   for (setDimnames in c(TRUE, FALSE)) {
  +     if (setDimnames) dimnames(x) <- dimnames
  +     else dimnames(x) <- NULL
  +     # Row/column ranges
  +     for (na.rm in c(FALSE, TRUE)) {
  +       # Check names attribute
  +       for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) {
  +         r0 <- rowSds_R(x, na.rm = na.rm, useNames = useNames)
  +         r1 <- rowSds(x, na.rm = na.rm, useNames = useNames)
  +         r1b <- rowSds_center(x, na.rm = na.rm, useNames = useNames)
  +         r2 <- colSds(t(x), na.rm = na.rm, useNames = useNames)
  +         r2b <- colSds_center(t(x), na.rm = na.rm, useNames = useNames)
  +         stopifnot(all.equal(r1, r2))
  +         stopifnot(all.equal(r1, r0))
  +         stopifnot(all.equal(r2, r0))
  +         stopifnot(all.equal(r1b, r2b))
  +         stopifnot(
  +           !any(is.infinite(r1)),
  +           !any(is.infinite(r2)),
  +           !any(is.infinite(r1b)),
  +           !any(is.infinite(r2b))
  +         )
  +       }
  +     }
  +   }
  + }
  mode: integer
   int [1:10, 1:5] NA NA NA NA NA NA NA NA NA NA ...
  mode: double
   num [1:10, 1:5] NA NA NA NA NA NA NA NA NA NA ...
  > 
  > 
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > # A 1x1 matrix
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > x <- matrix(0, nrow = 1L, ncol = 1L)
  > dimnames <- list("a", "A")
  > for (na.rm in c(FALSE, TRUE)) {
  +   cat("na.rm = ", na.rm, "\n", sep = "")
  +   
  +   # Test with and without dimnames on x
  +   for (setDimnames in c(TRUE, FALSE)) {
  +     if (setDimnames) dimnames(x) <- dimnames
  +     else dimnames(x) <- NULL
  +     # Row/column ranges
  +     for (na.rm in c(FALSE, TRUE)) {
  +       # Check names attribute
  +       for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) {
  +         r0 <- rowSds_R(x, na.rm = na.rm, useNames = useNames)
  +         r1 <- rowSds(x, na.rm = na.rm, useNames = useNames)
  +         r1b <- rowSds_center(x, na.rm = na.rm, useNames = useNames)
  +         r2 <- colSds(t(x), na.rm = na.rm, useNames = useNames)
  +         r2b <- colSds_center(t(x), na.rm = na.rm, useNames = useNames)
  +         stopifnot(all.equal(r1, r2))
  +         stopifnot(all.equal(r1, r0))
  +         stopifnot(all.equal(r2, r0))
  +         stopifnot(all.equal(r1b, r2b))
  +         stopifnot(
  +           !any(is.infinite(r1)),
  +           !any(is.infinite(r2)),
  +           !any(is.infinite(r1b)),
  +           !any(is.infinite(r2b))
  +         )
  +       }
  +     }
  +   }
  + }
  na.rm = FALSE
  na.rm = TRUE
  > 
  > proc.time()
     user  system elapsed 
     0.35    0.04    0.37 
Running the tests in 'tests/rowSds_subset.R' failed.
Complete output:
  > library("matrixStats")
  > 
  > ## Always allow testing of the 'center' argument (as long as it's not defunct)
  > options(matrixStats.center.onUse = "ignore")
  > 
  > ## Create isFALSE() if running on an old version of R
  > if (!exists("isFALSE", mode="function")) {
  +   isFALSE <- function(x) is.logical(x) && length(x) == 1L && !is.na(x) && !x
  + }
  > 
  > rowSds_R <- function(x, na.rm = FALSE, center = NULL, ..., useNames = NA) {
  +   suppressWarnings({
  +     sigma <- apply(x, MARGIN = 1L, FUN = sd, na.rm = na.rm)
  +   })
  +   stopifnot(!any(is.infinite(sigma)))
  +   
  +   # Keep naming support consistency same as rowSds()
  +   if (is.null(center) || ncol(x) <= 1L) {
  +     if (is.na(useNames) || isFALSE(useNames)) names(sigma) <- NULL
  +   }
  +   else if (isFALSE(useNames)) names(sigma) <- NULL
  +   sigma
  + }
  > 
  > colSds_R <- function(x, na.rm = FALSE, center = NULL, ..., useNames = NA) {
  +   suppressWarnings({
  +     sigma <- apply(x, MARGIN = 2L, FUN = sd, na.rm = na.rm)
  +   })
  +   stopifnot(!any(is.infinite(sigma)))
  +   
  +   # Keep naming support consistency same as colSds()
  +   if (is.null(center) || nrow(x) <= 1L) {
  +     if (is.na(useNames) || isFALSE(useNames)) names(sigma) <- NULL
  +   }
  +   else if (isFALSE(useNames)) names(sigma) <- NULL
  +   sigma
  + }
  > 
  > 
  > rowSds_center <- function(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = NA) {
  +   center <- rowWeightedMeans(x, cols = cols, na.rm = na.rm, useNames = FALSE)
  +   sigma <- rowSds(x, rows = rows, cols = cols, center = center, na.rm = na.rm, useNames = useNames)
  +   stopifnot(!any(is.infinite(sigma)))
  +   sigma
  + }
  > 
  > colSds_center <- function(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = NA) {
  +   center <- colWeightedMeans(x, rows = rows, na.rm = na.rm, useNames = FALSE)
  +   sigma <- colSds(x, rows = rows, cols = cols, center = center, na.rm = na.rm, useNames = useNames)
  +   stopifnot(!any(is.infinite(sigma)))
  +   sigma
  + }
  > 
  > 
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > # Subsetted tests
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > source("utils/validateIndicesFramework.R")
  > x <- matrix(runif(6 * 6, min = -6, max = 6), nrow = 6, ncol = 6)
  > storage.mode(x) <- "integer"
  > 
  > # To check names attribute
  > dimnames <- list(letters[1:6], LETTERS[1:6])
  > 
  > # Test with and without dimnames on x
  > for (setDimnames in c(TRUE, FALSE)) {
  +   if (setDimnames) dimnames(x) <- dimnames
  +   else dimnames(x) <- NULL
  + 
  +   count <- 0L
  +   for (rows in index_cases) {
  +     for (cols in index_cases) {
  +       count <- count + 1L
  +       na.rm <- c(TRUE, FALSE)[count %% 2 + 1]
  +       useNames <- c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)
  +       useNames <- useNames[count %% length(useNames) + 1]
  +       
  +       validateIndicesTestMatrix(x, rows, cols,
  +                                 ftest = rowSds, fsure = rowSds_R,
  +                                 na.rm = na.rm, useNames = useNames)
  +       validateIndicesTestMatrix(x, rows, cols,
  +                                 ftest = rowSds_center, fsure = rowSds_R,
  +                                 na.rm = na.rm, center = TRUE, useNames = useNames)
  + 
  +       validateIndicesTestMatrix(x, rows, cols,
  +                                 fcoltest = colSds, fsure = rowSds_R,
  +                                 na.rm = na.rm, useNames = useNames)
  +       validateIndicesTestMatrix(x, rows, cols,
  +                                 fcoltest = colSds_center, fsure = rowSds_R,
  +                                 na.rm = na.rm, center = TRUE, useNames = useNames)
  +     }
  +   }
  + }
  > 
  > proc.time()
     user  system elapsed 
     1.01    0.09    1.11 
Running the tests in 'tests/rowTabulates.R' failed.
Complete output:
  > library("matrixStats")
  > 
  > nrow <- 6L
  > ncol <- 5L
  > data <- matrix(0:4, nrow = nrow, ncol = ncol)
  > 
  > # To check names attribute
  > dimnames <- list(letters[1:6], LETTERS[1:5])
  > 
  > modes <- c("integer", "logical", "raw")
  > for (mode in modes) {
  +   cat(sprintf("Mode: %s...\n", mode))
  + 
  +   x <- data
  +   if (mode == "logical") x <- x - 2L
  +   if (mode != "raw") x[c(2,5,7)] <- NA_integer_
  +   storage.mode(x) <- mode
  +   print(x)
  + 
  +   unique_values <- unique(as.vector(x))
  +   nbr_of_unique_values <- length(unique_values)
  + 
  +   y <- rowTabulates(x)
  +   print(y)
  +   stopifnot(
  +     identical(dim(y), c(nrow, nbr_of_unique_values)),
  +     all(y >= 0)
  +   )
  +   if (mode != "raw") {
  +     y0 <- t(table(x, row(x), useNA = "always")[, seq_len(nrow(x))])
  +     stopifnot(all(y == y0))
  +   }
  +   # Check names attribute
  +   dimnames(x) <- dimnames
  +   y1 <- rowTabulates(x, useNames = FALSE)
  +   stopifnot(all.equal(y1, y))
  +   if (!matrixStats:::isUseNamesNADefunct()) {
  +     y2 <- rowTabulates(x, useNames = NA)
  +     stopifnot(all.equal(y2, y))
  +   }
  +   y <- rowTabulates(x, useNames = TRUE)
  +   stopifnot(identical(rownames(y), rownames(x)))
  +   dimnames(x) <- NULL
  + 
  +   y <- colTabulates(x)
  +   print(y)
  +   stopifnot(
  +     identical(dim(y), c(ncol, nbr_of_unique_values)),
  +     all(y >= 0)
  +   )
  +   if (mode != "raw") {
  +     y0 <- t(table(x, col(x), useNA = "always")[, seq_len(ncol(x))])
  +     stopifnot(all(y == y0))
  +   }
  +   # Check names attribute
  +   dimnames(x) <- dimnames
  +   y1 <- colTabulates(x, useNames = FALSE)
  +   stopifnot(all.equal(y1, y))
  +   if (!matrixStats:::isUseNamesNADefunct()) {
  +     y2 <- colTabulates(x, useNames = NA)
  +     stopifnot(all.equal(y2, y))
  +   }
  +   y <- colTabulates(x, useNames = TRUE)
  +   stopifnot(identical(rownames(y), colnames(x)))
  +   dimnames(x) <- NULL
  + 
  +   # Count only certain values
  +   if (mode == "integer") {
  +     subset <- c(0:2, NA_integer_)
  +   } else if (mode == "logical") {
  +     subset <- c(TRUE, FALSE, NA)
  +   } else {
  +     subset <- c(0:2)
  +   }
  +   y <- rowTabulates(x, values = subset)
  +   print(y)
  +   stopifnot(identical(dim(y), c(nrow, length(subset))))
  +   # Check names attribute
  +   dimnames(x) <- dimnames
  +   y1 <- rowTabulates(x, values = subset, useNames = FALSE)
  +   stopifnot(all.equal(y1, y))
  +   if (!matrixStats:::isUseNamesNADefunct()) {
  +     y2 <- rowTabulates(x, values = subset, useNames = NA)
  +     stopifnot(all.equal(y2, y))
  +   }  
  +   y <- rowTabulates(x, values = subset, useNames = TRUE)
  +   stopifnot(identical(rownames(y), rownames(x)))
  +   dimnames(x) <- NULL
  + 
  +   y <- colTabulates(x, values = subset)
  +   print(y)
  +   stopifnot(identical(dim(y), c(ncol, length(subset))))
  +   # Check names attribute
  +   dimnames(x) <- dimnames
  +   y1 <- colTabulates(x, values = subset, useNames = FALSE)
  +   stopifnot(all.equal(y1, y))
  +   if (!matrixStats:::isUseNamesNADefunct()) {
  +     y2 <- colTabulates(x, values = subset, useNames = NA)
  +     stopifnot(all.equal(y2, y))
  +   }
  +   y <- colTabulates(x, values = subset, useNames = TRUE)
  +   stopifnot(identical(rownames(y), colnames(x)))
  +   dimnames(x) <- NULL
  + 
  +   # Raw
  +   if (mode %in% c("integer", "raw")) {
  +     subset <- c(0:2)
  +     
  +     y <- rowTabulates(x, values = as.raw(subset))
  +     print(y)
  +     stopifnot(identical(dim(y), c(nrow, length(subset))))
  +     # Check names attribute
  +     dimnames(x) <- dimnames
  +     y1 <- rowTabulates(x, values = as.raw(subset), useNames = FALSE)
  +     stopifnot(all.equal(y1, y))
  +     if (!matrixStats:::isUseNamesNADefunct()) {
  +       y2 <- rowTabulates(x, values = as.raw(subset), useNames = NA)
  +       stopifnot(all.equal(y2, y))
  +     }
  +     y3 <- rowTabulates(x, values = as.raw(subset), useNames = TRUE)
  +     stopifnot(identical(rownames(y3), rownames(x)))
  +     dimnames(x) <- NULL
  +     
  +     y2 <- colTabulates(t(x), values = as.raw(subset))
  +     print(y2)
  +     stopifnot(
  +       identical(dim(y2), c(nrow, length(subset))),
  +       identical(y2, y)
  +     )
  +     # Check names attribute
  +     dimnames(x) <- dimnames
  +     y1 <- colTabulates(t(x), values = as.raw(subset), useNames = FALSE)
  +     stopifnot(all.equal(y1, y))
  +     if (!matrixStats:::isUseNamesNADefunct()) {
  +       y2 <- colTabulates(t(x), values = as.raw(subset), useNames = NA)
  +       stopifnot(all.equal(y2, y))
  +     }
  +     y <- colTabulates(t(x), values = as.raw(subset), useNames = TRUE)
  +     stopifnot(identical(rownames(y), colnames(t(x))))
  +     dimnames(x) <- NULL
  +   }
  + 
  +   cat(sprintf("Mode: %s...done\n", mode))
  + } # for (mode ...)
  Mode: integer...
       [,1] [,2] [,3] [,4] [,5]
  [1,]    0   NA    2    3    4
  [2,]   NA    2    3    4    0
  [3,]    2    3    4    0    1
  [4,]    3    4    0    1    2
  [5,]   NA    0    1    2    3
  [6,]    0    1    2    3    4
       0 1 2 3 4 <NA>
  [1,] 1 0 1 1 1    1
  [2,] 1 0 1 1 1    1
  [3,] 1 1 1 1 1    0
  [4,] 1 1 1 1 1    0
  [5,] 1 1 1 1 0    1
  [6,] 1 1 1 1 1    0
       0 1 2 3 4 <NA>
  [1,] 2 0 1 1 0    2
  [2,] 1 1 1 1 1    1
  [3,] 1 1 2 1 1    0
  [4,] 1 1 1 2 1    0
  [5,] 1 1 1 1 2    0
       0 1 2 <NA>
  [1,] 1 0 1    1
  [2,] 1 0 1    1
  [3,] 1 1 1    0
  [4,] 1 1 1    0
  [5,] 1 1 1    1
  [6,] 1 1 1    0
       0 1 2 <NA>
  [1,] 2 0 1    2
  [2,] 1 1 1    1
  [3,] 1 1 2    0
  [4,] 1 1 1    0
  [5,] 1 1 1    0
       0x0 0x1 0x2
  [1,]   1   0   1
  [2,]   1   0   1
  [3,]   1   1   1
  [4,]   1   1   1
  [5,]   1   1   1
  [6,]   1   1   1
       0x0 0x1 0x2
  [1,]   1   0   1
  [2,]   1   0   1
  [3,]   1   1   1
  [4,]   1   1   1
  [5,]   1   1   1
  [6,]   1   1   1
  Mode: integer...done
  Mode: logical...
        [,1]  [,2]  [,3]  [,4]  [,5]
  [1,]  TRUE    NA FALSE  TRUE  TRUE
  [2,]    NA FALSE  TRUE  TRUE  TRUE
  [3,] FALSE  TRUE  TRUE  TRUE  TRUE
  [4,]  TRUE  TRUE  TRUE  TRUE FALSE
  [5,]    NA  TRUE  TRUE FALSE  TRUE
  [6,]  TRUE  TRUE FALSE  TRUE  TRUE
       FALSE TRUE <NA>
  [1,]     1    3    1
  [2,]     1    3    1
  [3,]     1    4    0
  [4,]     1    4    0
  [5,]     1    3    1
  [6,]     1    4    0
       FALSE TRUE <NA>
  [1,]     1    3    2
  [2,]     1    4    1
  [3,]     2    4    0
  [4,]     1    5    0
  [5,]     1    5    0
       TRUE FALSE <NA>
  [1,]    3     1    1
  [2,]    3     1    1
  [3,]    4     1    0
  [4,]    4     1    0
  [5,]    3     1    1
  [6,]    4     1    0
       TRUE FALSE <NA>
  [1,]    3     1    2
  [2,]    4     1    1
  [3,]    4     2    0
  [4,]    5     1    0
  [5,]    5     1    0
  Mode: logical...done
  Mode: raw...
       [,1] [,2] [,3] [,4] [,5]
  [1,]   00   01   02   03   04
  [2,]   01   02   03   04   00
  [3,]   02   03   04   00   01
  [4,]   03   04   00   01   02
  [5,]   04   00   01   02   03
  [6,]   00   01   02   03   04
       0x0 0x1 0x2 0x3 0x4
  [1,]   1   1   1   1   1
  [2,]   1   1   1   1   1
  [3,]   1   1   1   1   1
  [4,]   1   1   1   1   1
  [5,]   1   1   1   1   1
  [6,]   1   1   1   1   1
       0x0 0x1 0x2 0x3 0x4
  [1,]   2   1   1   1   1
  [2,]   1   2   1   1   1
  [3,]   1   1   2   1   1
  [4,]   1   1   1   2   1
  [5,]   1   1   1   1   2
       0 1 2
  [1,] 1 1 1
  [2,] 1 1 1
  [3,] 1 1 1
  [4,] 1 1 1
  [5,] 1 1 1
  [6,] 1 1 1
       0 1 2
  [1,] 2 1 1
  [2,] 1 2 1
  [3,] 1 1 2
  [4,] 1 1 1
  [5,] 1 1 1
       0x0 0x1 0x2
  [1,]   1   1   1
  [2,]   1   1   1
  [3,]   1   1   1
  [4,]   1   1   1
  [5,]   1   1   1
  [6,]   1   1   1
       0x0 0x1 0x2
  [1,]   1   1   1
  [2,]   1   1   1
  [3,]   1   1   1
  [4,]   1   1   1
  [5,]   1   1   1
  [6,]   1   1   1
  Mode: raw...done
  > 
  > proc.time()
     user  system elapsed 
     0.39    0.09    0.45 
Running the tests in 'tests/rowTabulates_subset.R' failed.
Complete output:
  > library("matrixStats")
  > 
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > # Subsetted tests
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > source("utils/validateIndicesFramework.R")
  > x <- matrix(runif(6 * 6, min = -6, max = 6), nrow = 6, ncol = 6)
  > storage.mode(x) <- "integer"
  > 
  > # To check names attribute
  > dimnames <- list(letters[1:6], LETTERS[1:6])
  > 
  > # Test with and without dimnames on x
  > for (setDimnames in c(TRUE, FALSE)) {
  +   if (setDimnames) dimnames(x) <- dimnames
  +   else dimnames(x) <- NULL
  +   
  +   count <- 0L
  +   for (rows in index_cases) {
  +     for (cols in index_cases) {
  +       count <- count + 1L
  +       useNames <- c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)
  +       useNames <- useNames[count %% length(useNames) + 1]
  +       
  +       validateIndicesTestMatrix(x, rows, cols,
  +                                 ftest = rowTabulates, fsure = rowTabulates, useNames = useNames)
  +       validateIndicesTestMatrix(x, rows, cols,
  +                                 ftest = rowTabulates, fsure = rowTabulates,
  +                                 values = 1:3, useNames = useNames)
  +   
  +       validateIndicesTestMatrix(x, rows, cols,
  +                                 ftest = colTabulates, fsure = colTabulates, useNames = useNames)
  +       validateIndicesTestMatrix(x, rows, cols,
  +                                 ftest = colTabulates, fsure = colTabulates,
  +                                 values = 1:3, useNames = useNames)
  +     }
  +   }
  + }
  > 
  > proc.time()
     user  system elapsed 
     1.90    0.10    1.98 
Running the tests in 'tests/rowVars.R' failed.
Complete output:
  > library("matrixStats")
  > 
  > ## Always allow testing of the 'center' argument (as long as it's not defunct)
  > options(matrixStats.center.onUse = "ignore")
  > options(matrixStats.vars.formula.freq = Inf)
  > 
  > ## Create isFALSE() if running on an old version of R
  > if (!exists("isFALSE", mode="function")) {
  +   isFALSE <- function(x) is.logical(x) && length(x) == 1L && !is.na(x) && !x
  + }
  > 
  > rowVars_R <- function(x, na.rm = FALSE, center = NULL, ..., useNames = NA) {
  +   suppressWarnings({
  +     res <- apply(x, MARGIN = 1L, FUN = var, na.rm = na.rm)
  +   })
  +   stopifnot(!any(is.infinite(res)))
  +   
  +   # Keep naming support consistency same as rowVars()
  +   if (is.null(center) || ncol(x) <= 1L) {
  +     if (is.na(useNames) || isFALSE(useNames)) names(res) <- NULL
  +   }
  +   else if (isFALSE(useNames)) names(res) <- NULL
  +   res
  + }
  > 
  > colVars_R <- function(x, na.rm = FALSE, center = NULL, ..., useNames = NA) {
  +   suppressWarnings({
  +     res <- apply(x, MARGIN = 2L, FUN = var, na.rm = na.rm)
  +   })
  +   stopifnot(!any(is.infinite(res)))
  +   
  +   # Keep naming support consistency same as colVars()
  +   if (is.null(center) || ncol(x) <= 1L) {
  +     if (is.na(useNames) || isFALSE(useNames)) names(res) <- NULL
  +   }
  +   else if (isFALSE(useNames)) names(res) <- NULL
  +   res
  + }
  > 
  > 
  > rowVars_center <- function(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = NA) {
  +   center <- rowWeightedMeans(x, cols = cols, na.rm = na.rm, useNames = FALSE)
  +   res <- rowVars(x, rows = rows, cols = cols, center = center, na.rm = na.rm, useNames = useNames)
  +   stopifnot(!any(is.infinite(res)))
  +   res
  + }
  > 
  > colVars_center <- function(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = NA) {
  +   center <- colWeightedMeans(x, rows = rows, na.rm = na.rm, useNames = FALSE)
  +   res <- colVars(x, rows = rows, cols = cols, center = center, na.rm = na.rm, useNames = useNames)
  +   stopifnot(!any(is.infinite(res)))
  +   res
  + }
  > 
  > rowVars_center_naive <- function(x, rows = NULL, cols = NULL, center = NULL, na.rm = FALSE, ..., useNames = NA) {
  +   x <- sweep(x, MARGIN = 1, STATS = as.array(center), FUN = "-")
  +   x[is.infinite(center), ] <- NaN
  +   res <- rowVars(x, rows = rows, cols = cols, center = rep(0, times = nrow(x)), na.rm = na.rm, useNames = useNames)
  +   stopifnot(!any(is.infinite(res)))
  +   res
  + }
  > 
  > colVars_center_naive <- function(x, rows = NULL, cols = NULL, center = NULL, na.rm = FALSE, ..., useNames = NA) {
  +   x <- sweep(x, MARGIN = 2, STATS = as.array(center), FUN = "-")
  +   x[, is.infinite(center)] <- NaN
  +   res <- colVars(x, rows = rows, cols = cols, center = rep(0, times = ncol(x)), na.rm = na.rm, useNames = useNames)
  +   stopifnot(!any(is.infinite(res)))
  +   res
  + }
  > 
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > # With and without some NAs or Infs
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > for (mode in c("integer", "double")) {
  +   if (mode == "integer") {
  +     specials <- c(0L, NA_integer_)
  +     delta <- 0L
  +   } else {
  +     specials <- c(0, NA_real_, Inf)
  +     delta <- 0.1
  +   }
  +   
  +   for (special in specials) {
  +     cat("special = ", special, "\n", sep = "")
  +     x <- matrix(1:50 + delta, nrow = 10L, ncol = 5L)
  +     x[3:7, c(2, 4)] <- special
  +     cat("mode: ", mode, "\n", sep = "")
  +     str(x)
  +     stopifnot(storage.mode(x) == mode)
  +     
  +     # To check names attribute
  +     dimnames <- list(letters[1:10], LETTERS[1:5])
  +     
  +     # Test with and without dimnames on x
  +     for (setDimnames in c(TRUE, FALSE)) {
  +       if (setDimnames) dimnames(x) <- dimnames
  +       else dimnames(x) <- NULL
  +       # Row/column variance
  +       for (na.rm in c(FALSE, TRUE)) {
  +         # Check names attribute
  +         for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) {
  +           cat("na.rm = ", na.rm, "\n", sep = "")
  +           center <- rowMeans(x, na.rm = na.rm)
  +           
  +           r0 <- rowVars_R(x, na.rm = na.rm, useNames = useNames)
  +           r1 <- rowVars(x, na.rm = na.rm, useNames = useNames)
  +           r1b <- rowVars_center(x, na.rm = na.rm, useNames = useNames)
  +           r1c <- rowVars(x, center = center, na.rm = na.rm, useNames = useNames)
  +           
  +           tx <- t(x)
  +           r2 <- colVars(tx, na.rm = na.rm, useNames = useNames)
  +           r2b <- colVars_center(tx, na.rm = na.rm, useNames = useNames)
  +           r2c <- colVars(tx, center = center, na.rm = na.rm, useNames = useNames)
  +           tx <- NULL
  +           
  +           stopifnot(all.equal(r1, r2))
  +           stopifnot(all.equal(r1, r0))
  +           stopifnot(all.equal(r1b, r1c))
  +           stopifnot(all.equal(r2, r0))
  +           stopifnot(all.equal(r2b, r2c))
  +           
  +           center <- colMeans(x, na.rm = na.rm)
  + 
  +           r3 <- colVars(x, center = center, na.rm = na.rm, useNames = useNames)
  +           r3b <- colVars_center_naive(x, center = center, na.rm = na.rm, useNames = useNames)
  +           r3c <- rowVars(t(x), center = center, na.rm = na.rm, useNames = useNames)
  +           r3d <- rowVars_center_naive(t(x), center = center, na.rm = na.rm, useNames = useNames)
  +           stopifnot(all.equal(r3b, r3))
  +           stopifnot(all.equal(r3c, r3))
  +           stopifnot(all.equal(r3d, r3))
  +           
  +           stopifnot(
  +             !any(is.infinite(r0)),
  +             !any(is.infinite(r1)),
  +             !any(is.infinite(r2)),
  +             !any(is.infinite(r3)),
  +             !any(is.infinite(r1b)),
  +             !any(is.infinite(r1c)),
  +             !any(is.infinite(r2b)),
  +             !any(is.infinite(r2c)),
  +             !any(is.infinite(r3b)),
  +             !any(is.infinite(r3c)),
  +             !any(is.infinite(r3d))
  +           )
  +         }
  +       }
  +     }
  +   } # for (special ...)
  + }
  special = 0
  mode: integer
   int [1:10, 1:5] 1 2 3 4 5 6 7 8 9 10 ...
  na.rm = FALSE
  na.rm = FALSE
  na.rm = TRUE
  na.rm = TRUE
  na.rm = FALSE
  na.rm = FALSE
  na.rm = TRUE
  na.rm = TRUE
  special = NA
  mode: integer
   int [1:10, 1:5] 1 2 3 4 5 6 7 8 9 10 ...
  na.rm = FALSE
  na.rm = FALSE
  na.rm = TRUE
  na.rm = TRUE
  na.rm = FALSE
  na.rm = FALSE
  na.rm = TRUE
  na.rm = TRUE
  special = 0
  mode: double
   num [1:10, 1:5] 1.1 2.1 3.1 4.1 5.1 6.1 7.1 8.1 9.1 10.1 ...
  na.rm = FALSE
  na.rm = FALSE
  na.rm = TRUE
  na.rm = TRUE
  na.rm = FALSE
  na.rm = FALSE
  na.rm = TRUE
  na.rm = TRUE
  special = NA
  mode: double
   num [1:10, 1:5] 1.1 2.1 3.1 4.1 5.1 6.1 7.1 8.1 9.1 10.1 ...
  na.rm = FALSE
  na.rm = FALSE
  na.rm = TRUE
  na.rm = TRUE
  na.rm = FALSE
  na.rm = FALSE
  na.rm = TRUE
  na.rm = TRUE
  special = Inf
  mode: double
   num [1:10, 1:5] 1.1 2.1 3.1 4.1 5.1 6.1 7.1 8.1 9.1 10.1 ...
  na.rm = FALSE
  na.rm = FALSE
  na.rm = TRUE
  na.rm = TRUE
  na.rm = FALSE
  na.rm = FALSE
  na.rm = TRUE
  na.rm = TRUE
  > 
  > 
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > # All NAs
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > for (mode in c("integer", "double")) {
  +   x <- matrix(NA_real_, nrow = 10L, ncol = 5L)
  +   cat("mode: ", mode, "\n", sep = "")
  +   storage.mode(x) <- mode
  +   str(x)
  +   
  +   # Test with and without dimnames on x
  +   for (setDimnames in c(TRUE, FALSE)) {
  +     if (setDimnames) dimnames(x) <- dimnames
  +     else dimnames(x) <- NULL
  +     # Row/column variance
  +     for (na.rm in c(FALSE, TRUE)) {
  +       # Check names attribute
  +       for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) {
  +         cat("na.rm = ", na.rm, "\n", sep = "")
  +         
  +         r0 <- rowVars_R(x, na.rm = na.rm, useNames = useNames)
  +         r1 <- rowVars(x, na.rm = na.rm, useNames = useNames)
  +         r1b <- rowVars_center(x, na.rm = na.rm, useNames = useNames)
  +         r2 <- colVars(t(x), na.rm = na.rm, useNames = useNames)
  +         r2b <- colVars_center(t(x), na.rm = na.rm, useNames = useNames)
  +         stopifnot(all.equal(r1, r2))
  +         stopifnot(all.equal(r1, r0))
  +         stopifnot(all.equal(r2, r0))
  +         stopifnot(all.equal(r1b, r2b))
  +         stopifnot(
  +           !any(is.infinite(r0)),
  +           !any(is.infinite(r1)),
  +           !any(is.infinite(r2)),
  +           !any(is.infinite(r1b)),
  +           !any(is.infinite(r2b))
  +         )
  +       }
  +     }
  +   }
  + }
  mode: integer
   int [1:10, 1:5] NA NA NA NA NA NA NA NA NA NA ...
  na.rm = FALSE
  na.rm = FALSE
  na.rm = TRUE
  na.rm = TRUE
  na.rm = FALSE
  na.rm = FALSE
  na.rm = TRUE
  na.rm = TRUE
  mode: double
   num [1:10, 1:5] NA NA NA NA NA NA NA NA NA NA ...
  na.rm = FALSE
  na.rm = FALSE
  na.rm = TRUE
  na.rm = TRUE
  na.rm = FALSE
  na.rm = FALSE
  na.rm = TRUE
  na.rm = TRUE
  > 
  > 
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > # A 1x1 matrix
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > x <- matrix(0, nrow = 1L, ncol = 1L)
  > dimnames <- list("a", "A")
  > # Test with and without dimnames on x
  > for (setDimnames in c(TRUE, FALSE)) {
  +   if (setDimnames) dimnames(x) <- dimnames
  +   else dimnames(x) <- NULL
  +   # Row/column variance
  +   for (na.rm in c(FALSE, TRUE)) {
  +     # Check names attribute
  +     for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) {
  +       cat("na.rm = ", na.rm, "\n", sep = "")
  +       
  +       r0 <- rowVars_R(x, na.rm = na.rm, useNames = useNames)
  +       r1 <- rowVars(x, na.rm = na.rm, useNames = useNames)
  +       r1b <- rowVars_center(x, na.rm = na.rm, useNames = useNames)
  +       r2 <- colVars(t(x), na.rm = na.rm, useNames = useNames)
  +       r2b <- colVars_center(t(x), na.rm = na.rm, useNames = useNames)
  +       stopifnot(all.equal(r1, r2))
  +       stopifnot(all.equal(r1, r0))
  +       stopifnot(all.equal(r2, r0))
  +       stopifnot(all.equal(r1b, r2b))
  +       stopifnot(
  +         !any(is.infinite(r0)),
  +         !any(is.infinite(r1)),
  +         !any(is.infinite(r2)),
  +         !any(is.infinite(r1b)),
  +         !any(is.infinite(r2b))
  +       )
  +     }
  +   }
  + }
  na.rm = FALSE
  na.rm = FALSE
  na.rm = TRUE
  na.rm = TRUE
  na.rm = FALSE
  na.rm = FALSE
  na.rm = TRUE
  na.rm = TRUE
  > 
  > 
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > # center and .dim
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > m <- matrix(1:12, nrow = 3L, ncol = 4L)
  > a <- array(m, dim = c(3, 2, 2))
  > stopifnot(prod(dim(a)) == prod(dim(m)))
  > 
  > y0 <- rowVars(m, dim. = dim(m))
  > print(y0)
  [1] 15 15 15
  > y1 <- rowVars(a, dim. = dim(m))
  > print(y1)
  [1] 15 15 15
  > stopifnot(identical(y1, y0))
  > stopifnot(
  +   !any(is.infinite(y0)),
  +   !any(is.infinite(y1))
  + )
  > 
  > mu <- rowMeans(m)
  > y0 <- rowVars(m, center = mu, dim. = dim(m))
  > print(y0)
  [1] 15 15 15
  > y1 <- rowVars(a, center = mu, dim. = dim(m))
  > print(y1)
  [1] 15 15 15
  > stopifnot(identical(y1, y0))
  > stopifnot(
  +   !any(is.infinite(y0)),
  +   !any(is.infinite(y1))
  + )
  > 
  > 
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > # Corner cases
  > # https://github.com/HenrikBengtsson/matrixStats/issues/195
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > x <- matrix(c(1,2,3,4), nrow = 2L, ncol = 2L)
  > x[1,1] <- NA_real_
  > x[1,2] <- Inf
  > 
  > center <- colMeans2(x, na.rm = TRUE)
  > y <- colVars(x, center = center, na.rm = TRUE)
  > stopifnot(!any(is.infinite(y)))
  > 
  > x <- t(x)
  > center <- rowMeans2(x, na.rm = TRUE)
  > y <- rowVars(x, center = center, na.rm = TRUE)
  > stopifnot(!any(is.infinite(y)))
  > 
  > proc.time()
     user  system elapsed 
     0.40    0.04    0.43 
Running the tests in 'tests/rowVars_subset.R' failed.
Complete output:
  > library("matrixStats")
  > 
  > ## Always allow testing of the 'center' argument (as long as it's not defunct)
  > options(matrixStats.center.onUse = "ignore")
  > 
  > ## Create isFALSE() if running on an old version of R
  > if (!exists("isFALSE", mode="function")) {
  +   isFALSE <- function(x) is.logical(x) && length(x) == 1L && !is.na(x) && !x
  + }
  > 
  > rowVars_R <- function(x, na.rm = FALSE, center = NULL, ..., useNames = NA) {
  +   suppressWarnings({
  +     res <- apply(x, MARGIN = 1L, FUN = var, na.rm = na.rm)
  +   })
  +   stopifnot(!any(is.infinite(res)))
  +   
  +   # Keep naming support consistency same as rowVars()
  +   if (is.null(center) || ncol(x) <= 1L) {
  +     if (is.na(useNames) || isFALSE(useNames)) names(res) <- NULL
  +   }
  +   else if (isFALSE(useNames)) names(res) <- NULL
  +   res
  + }
  > 
  > colVars_R <- function(x, na.rm = FALSE, center = NULL, ..., useNames = NA) {
  +   suppressWarnings({
  +     res <- apply(x, MARGIN = 2L, FUN = var, na.rm = na.rm)
  +   })
  +   stopifnot(!any(is.infinite(res)))
  +   
  +   # Keep naming support consistency same as colVars()
  +   if (is.null(center) || nrow(x) <= 1L) {
  +     if (is.na(useNames) || isFALSE(useNames)) names(res) <- NULL
  +   }
  +   else if (isFALSE(useNames)) names(res) <- NULL
  +   res
  + }
  > 
  > 
  > rowVars_center <- function(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = NA) {
  +   center <- rowWeightedMeans(x, cols = cols, na.rm = na.rm, useNames = FALSE)
  +   res <- rowVars(x, rows = rows, cols = cols, center = center, na.rm = na.rm, useNames = useNames)
  +   stopifnot(!any(is.infinite(res)))
  +   res
  + }
  > 
  > colVars_center <- function(x, rows = NULL, cols = NULL, na.rm = FALSE, ..., useNames = NA) {
  +   center <- colWeightedMeans(x, rows = rows, na.rm = na.rm, useNames = FALSE)
  +   res <- colVars(x, rows = rows, cols = cols, center = center, na.rm = na.rm, useNames = useNames)
  +   stopifnot(!any(is.infinite(res)))
  +   res
  + }
  > 
  > 
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > # Subsetted tests
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > source("utils/validateIndicesFramework.R")
  > x <- matrix(runif(6 * 6, min = -6, max = 6), nrow = 6, ncol = 6)
  > storage.mode(x) <- "integer"
  > 
  > # To check names attribute
  > dimnames <- list(letters[1:6], LETTERS[1:6])
  > 
  > # Test with and without dimnames on x
  > for (setDimnames in c(TRUE, FALSE)) {
  +   if (setDimnames) dimnames(x) <- dimnames
  +   else dimnames(x) <- NULL
  + 
  +   count <- 0L
  +   for (rows in index_cases) {
  +     for (cols in index_cases) {
  +       count <- count + 1L
  +       na.rm <- c(TRUE, FALSE)[count %% 2 + 1]
  +       useNames <- c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)
  +       useNames <- useNames[count %% length(useNames) + 1]
  +       
  +       validateIndicesTestMatrix(x, rows, cols,
  +                                 ftest = rowVars, fsure = rowVars_R,
  +                                 na.rm = na.rm, useNames = useNames)
  +       validateIndicesTestMatrix(x, rows, cols,
  +                                 ftest = rowVars_center, fsure = rowVars_R,
  +                                 na.rm = na.rm, center = TRUE, useNames = useNames)
  + 
  +       validateIndicesTestMatrix(x, rows, cols,
  +                                 fcoltest = colVars, fsure = rowVars_R,
  +                                 na.rm = na.rm, useNames = useNames)
  +       validateIndicesTestMatrix(x, rows, cols,
  +                                 fcoltest = colVars_center, fsure = rowVars_R,
  +                                 na.rm = na.rm, center = TRUE, useNames = useNames)
  +     }
  +   }
  + }
  > 
  > proc.time()
     user  system elapsed 
     1.07    0.09    1.17 
Running the tests in 'tests/rowWeightedMeans.R' failed.
Complete output:
  > library("matrixStats")
  > 
  > ## Create isFALSE() if running on an old version of R
  > if (!exists("isFALSE", mode="function")) {
  +   isFALSE <- function(x) is.logical(x) && length(x) == 1L && !is.na(x) && !x
  + }
  > 
  > rowWeightedMeans_R <- function(x, w, na.rm = FALSE, ..., useNames = NA) {
  +   res <- apply(x, MARGIN = 1L, FUN = weighted.mean, w = w, na.rm = na.rm, ...)
  +   
  +   # Keep naming support consistency same as rowWeightedMeans()
  +   idxs <- which(is.na(w) | w != 0)
  +   nw <- length(idxs)
  +   if (na.rm) na.rm <- anyMissing(x)
  +   if ((!is.null(w) && nw == 0L) || isFALSE(na.rm)) {
  +     if (is.na(useNames) || !useNames) names(res) <- NULL
  +   }
  +   else if (isFALSE(useNames)) names(res) <- NULL
  +   
  +   res
  + }
  > 
  > colWeightedMeans_R <- function(x, w, na.rm = FALSE, ..., useNames = NA) {
  +   res <- apply(x, MARGIN = 2L, FUN = weighted.mean, w = w, na.rm = na.rm, ...)
  +   
  +   # Keep naming support consistency same as colWeightedMeans()
  +   idxs <- which(is.na(w) | w != 0)
  +   nw <- length(idxs)
  +   if (!is.null(w) && nw == 0L) {
  +     if (is.na(useNames) || !useNames) names(res) <- NULL
  +   }
  +   else if (isFALSE(useNames)) names(res) <- NULL
  +   
  +   res
  + }
  > 
  > set.seed(1)
  > 
  > x <- matrix(rnorm(20), nrow = 5, ncol = 4)
  > print(x)
             [,1]       [,2]       [,3]        [,4]
  [1,] -0.6264538 -0.8204684  1.5117812 -0.04493361
  [2,]  0.1836433  0.4874291  0.3898432 -0.01619026
  [3,] -0.8356286  0.7383247 -0.6212406  0.94383621
  [4,]  1.5952808  0.5757814 -2.2146999  0.82122120
  [5,]  0.3295078 -0.3053884  1.1249309  0.59390132
  > 
  > # To check names attribute
  > dimnames <- list(letters[1:5], LETTERS[1:4])
  > 
  > # Non-weighted row averages
  > x_est0 <- rowMeans(x)
  > x_est1 <- rowWeightedMeans(x)
  > print(x_est1)
  [1] 0.004981341 0.261181337 0.056322931 0.194395865 0.435737906
  > stopifnot(all.equal(x_est1, x_est0))
  > x_est2 <- colWeightedMeans(t(x))
  > stopifnot(all.equal(x_est2, x_est0))
  > # Check names attribute
  > dimnames(x) <- dimnames
  > x_est1 <- rowWeightedMeans(x, useNames = FALSE)
  > x_est2 <- colWeightedMeans(t(x), useNames = FALSE)
  > stopifnot(all.equal(x_est1, x_est0))
  > stopifnot(all.equal(x_est2, x_est0))
  > x_est0 <- rowMeans(x)
  > x_est1 <- rowWeightedMeans(x, useNames = TRUE)
  > x_est2 <- colWeightedMeans(t(x), useNames = TRUE)
  > stopifnot(all.equal(x_est1, x_est0))
  > stopifnot(all.equal(x_est2, x_est0))
  > dimnames(x) <- NULL
  > 
  > 
  > # Weighted row averages (uniform weights)
  > w <- rep(2.5, times = ncol(x))
  > x_est0 <- rowMeans(x)
  > x_est1 <- rowWeightedMeans(x, w = w)
  > print(x_est1)
  [1] 0.004981341 0.261181337 0.056322931 0.194395865 0.435737906
  > stopifnot(all.equal(x_est1, x_est0))
  > x_est2 <- colWeightedMeans(t(x), w = w)
  > stopifnot(all.equal(x_est2, x_est0))
  > # Test with and without dimnames on x
  > for (setDimnames in c(TRUE, FALSE)) {
  +   if (setDimnames) dimnames(x) <- dimnames
  +   else dimnames(x) <- NULL    
  +   # Check names attribute
  +   for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) {
  +     x_est0 <- rowWeightedMeans_R(x, w = w, useNames = useNames)
  +     x_est1 <- rowWeightedMeans(x, w = w, useNames = useNames)
  +     stopifnot(all.equal(x_est1, x_est0))
  +     x_est0 <- colWeightedMeans_R(t(x), w = w, useNames = useNames)
  +     x_est1 <- colWeightedMeans(t(x), w = w, useNames = useNames)
  +     stopifnot(all.equal(x_est1, x_est0))
  +   }
  + }
  > 
  > 
  > # Weighted row averages (excluding some columns)
  > w <- c(1, 1, 0, 1)
  > x_est0 <- rowMeans(x[, (w == 1), drop = FALSE])
  > x_est1 <- rowWeightedMeans(x, w = w)
  > print(x_est1)
  [1] -0.4972853  0.2182940  0.2821774  0.9974278  0.2060069
  > stopifnot(all.equal(x_est1, x_est0))
  > x_est2 <- colWeightedMeans(t(x), w = w)
  > stopifnot(all.equal(x_est2, x_est0))
  > # Test with and without dimnames on x
  > for (setDimnames in c(TRUE, FALSE)) {
  +   if (setDimnames) dimnames(x) <- dimnames
  +   else dimnames(x) <- NULL    
  +   # Check names attribute
  +   for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) {
  +     x_est0 <- rowWeightedMeans_R(x, w = w, useNames = useNames)
  +     x_est1 <- rowWeightedMeans(x, w = w, useNames = useNames)
  +     stopifnot(all.equal(x_est1, x_est0))
  +     x_est0 <- colWeightedMeans_R(t(x), w = w, useNames = useNames)
  +     x_est1 <- colWeightedMeans(t(x), w = w, useNames = useNames)
  +     stopifnot(all.equal(x_est1, x_est0))
  +   }
  + }
  > 
  > 
  > # Weighted row averages (excluding some columns)
  > w <- c(0, 1, 0, 0)
  > x_est0 <- rowMeans(x[, (w == 1), drop = FALSE])
  > x_est1 <- rowWeightedMeans(x, w = w)
  > stopifnot(all.equal(x_est1, x_est0))
  > x_est2 <- colWeightedMeans(t(x), w = w)
  > stopifnot(all.equal(x_est2, x_est0))
  > # Test with and without dimnames on x
  > for (setDimnames in c(TRUE, FALSE)) {
  +   if (setDimnames) dimnames(x) <- dimnames
  +   else dimnames(x) <- NULL    
  +   # Check names attribute
  +   for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) {
  +     x_est0 <- rowWeightedMeans_R(x, w = w, useNames = useNames)
  +     x_est1 <- rowWeightedMeans(x, w = w, useNames = useNames)
  +     stopifnot(all.equal(x_est1, x_est0))
  +     x_est0 <- colWeightedMeans_R(t(x), w = w, useNames = useNames)
  +     x_est1 <- colWeightedMeans(t(x), w = w, useNames = useNames)
  +     stopifnot(all.equal(x_est1, x_est0))
  +   }
  + }
  > 
  > 
  > # Weighted row averages (all zero weights)
  > w <- c(0, 0, 0, 0)
  > x_est0 <- rowMeans(x[, (w == 1), drop = FALSE])
  > x_est1 <- rowWeightedMeans(x, w = w)
  > stopifnot(all.equal(x_est1, x_est0))
  > x_est2 <- colWeightedMeans(t(x), w = w)
  > stopifnot(all.equal(x_est2, x_est0))
  > # Test with and without dimnames on x
  > for (setDimnames in c(TRUE, FALSE)) {
  +   if (setDimnames) dimnames(x) <- dimnames
  +   else dimnames(x) <- NULL    
  +   # Check names attribute
  +   for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) {
  +     x_est0 <- rowWeightedMeans_R(x, w = w, useNames = useNames)
  +     x_est1 <- rowWeightedMeans(x, w = w, useNames = useNames)
  +     stopifnot(all.equal(x_est1, x_est0))
  +     x_est0 <- colWeightedMeans_R(t(x), w = w, useNames = useNames)
  +     x_est1 <- colWeightedMeans(t(x), w = w, useNames = useNames)
  +     stopifnot(all.equal(x_est1, x_est0))
  +   }
  + }
  > 
  > 
  > # Weighted averages by rows and columns
  > w <- 1:4
  > x_est1 <- rowWeightedMeans(x, w = w)
  > print(x_est1)
  [1]  0.20882185  0.22632701  0.25526439 -0.06123714  0.54691290
  > x_est2 <- colWeightedMeans(t(x), w = w)
  > stopifnot(all.equal(x_est2, x_est1))
  > # Test with and without dimnames on x
  > for (setDimnames in c(TRUE, FALSE)) {
  +   if (setDimnames) dimnames(x) <- dimnames
  +   else dimnames(x) <- NULL    
  +   # Check names attribute
  +   for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) {
  +     x_est0 <- rowWeightedMeans_R(x, w = w, useNames = useNames)
  +     x_est1 <- rowWeightedMeans(x, w = w, useNames = useNames)
  +     stopifnot(all.equal(x_est1, x_est0))
  +     x_est0 <- colWeightedMeans_R(t(x), w = w, useNames = useNames)
  +     x_est1 <- colWeightedMeans(t(x), w = w, useNames = useNames)
  +     stopifnot(all.equal(x_est1, x_est0))
  +   }
  + }
  > 
  > 
  > x[sample(length(x), size = 0.3 * length(x))] <- NA
  > print(x)
             [,1]      [,2]       [,3]        [,4]
  [1,] -0.6264538        NA  1.5117812 -0.04493361
  [2,]  0.1836433        NA         NA -0.01619026
  [3,] -0.8356286 0.7383247 -0.6212406  0.94383621
  [4,]  1.5952808        NA -2.2146999  0.82122120
  [5,]  0.3295078        NA         NA  0.59390132
  > 
  > # Non-weighted row averages with missing values
  > x_est0 <- rowMeans(x, na.rm = TRUE)
  > x_est1 <- rowWeightedMeans(x, na.rm = TRUE)
  > print(x_est1)
  [1] 0.28013125 0.08372653 0.05632293 0.06726737 0.46170455
  > stopifnot(all.equal(x_est1, x_est0))
  > x_est2 <- colWeightedMeans(t(x), na.rm = TRUE)
  > stopifnot(all.equal(x_est2, x_est0))
  > # Check names attribute
  > dimnames(x) <- dimnames
  > x_est1 <- rowWeightedMeans(x, na.rm = TRUE, useNames = FALSE)
  > x_est2 <- colWeightedMeans(t(x), na.rm = TRUE, useNames = FALSE)
  > stopifnot(all.equal(x_est1, x_est0))
  > stopifnot(all.equal(x_est2, x_est0))
  > x_est0 <- rowMeans(x, na.rm = TRUE)
  > x_est1 <- rowWeightedMeans(x, na.rm = TRUE, useNames = TRUE)
  > x_est2 <- colWeightedMeans(t(x), na.rm = TRUE, useNames = TRUE)
  > stopifnot(all.equal(x_est1, x_est0))
  > stopifnot(all.equal(x_est2, x_est0))
  > dimnames(x) <- NULL
  > 
  > 
  > # Weighted row averages with missing values
  > x_est0 <- apply(x, MARGIN = 1L, FUN = weighted.mean, w = w, na.rm = TRUE)
  > print(x_est0)
  [1]  0.46614441  0.02377645  0.25526439 -0.22049176  0.54102261
  > x_est1 <- rowWeightedMeans(x, w = w, na.rm = TRUE)
  > print(x_est1)
  [1]  0.46614441  0.02377645  0.25526439 -0.22049176  0.54102261
  > stopifnot(all.equal(x_est1, x_est0))
  > x_est2 <- colWeightedMeans(t(x), w = w, na.rm = TRUE)
  > stopifnot(all.equal(x_est2, x_est0))
  > # Test with and without dimnames on x
  > for (setDimnames in c(TRUE, FALSE)) {
  +   if (setDimnames) dimnames(x) <- dimnames
  +   else dimnames(x) <- NULL    
  +   # Check names attribute
  +   for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) {
  +     x_est0 <- rowWeightedMeans_R(x, w = w, na.rm = TRUE, useNames = useNames)
  +     x_est1 <- rowWeightedMeans(x, w = w, na.rm = TRUE, useNames = useNames)
  +     stopifnot(all.equal(x_est1, x_est0))
  +     x_est0 <- colWeightedMeans_R(t(x), w = w, na.rm = TRUE, useNames = useNames)
  +     x_est1 <- colWeightedMeans(t(x), w = w, na.rm = TRUE, useNames = useNames)
  +     stopifnot(all.equal(x_est1, x_est0))
  +   }
  + }
  > 
  > 
  > # Weighted averages by rows and columns
  > w <- 1:4
  > x_est1 <- rowWeightedMeans(x, w = w, na.rm = TRUE)
  > x_est2 <- colWeightedMeans(t(x), w = w, na.rm = TRUE)
  > stopifnot(all.equal(x_est2, x_est1))
  > # Test with and without dimnames on x
  > for (setDimnames in c(TRUE, FALSE)) {
  +   if (setDimnames) dimnames(x) <- dimnames
  +   else dimnames(x) <- NULL    
  +   # Check names attribute
  +   for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) {
  +     x_est0 <- rowWeightedMeans_R(x, w = w, na.rm = TRUE, useNames = useNames)
  +     x_est1 <- rowWeightedMeans(x, w = w, na.rm = TRUE, useNames = useNames)
  +     stopifnot(all.equal(x_est1, x_est0))
  +     x_est0 <- colWeightedMeans_R(t(x), w = w, na.rm = TRUE, useNames = useNames)
  +     x_est1 <- colWeightedMeans(t(x), w = w, na.rm = TRUE, useNames = useNames)
  +     stopifnot(all.equal(x_est1, x_est0))
  +   }
  + }
  > 
  > 
  > # w contains missing value
  > w[1] <- NA_integer_
  > x_est1 <- rowWeightedMeans(x, w = w, na.rm = TRUE)
  > x_est2 <- colWeightedMeans(t(x), w = w, na.rm = TRUE)
  > stopifnot(all.equal(x_est2, x_est1))
  > # Test with and without dimnames on x
  > for (setDimnames in c(TRUE, FALSE)) {
  +   if (setDimnames) dimnames(x) <- dimnames
  +   else dimnames(x) <- NULL    
  +   # Check names attribute
  +   for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) {
  +     x_est0 <- rowWeightedMeans_R(x, w = w, na.rm = TRUE, useNames = useNames)
  +     x_est1 <- rowWeightedMeans(x, w = w, na.rm = TRUE, useNames = useNames)
  +     stopifnot(all.equal(x_est1, x_est0))
  +     x_est0 <- colWeightedMeans_R(t(x), w = w, na.rm = TRUE, useNames = useNames)
  +     x_est1 <- colWeightedMeans(t(x), w = w, na.rm = TRUE, useNames = useNames)
  +     stopifnot(all.equal(x_est1, x_est0))
  +   }
  + }
  > 
  > x_est1 <- rowWeightedMeans(x, w = w, na.rm = FALSE)
  > x_est2 <- colWeightedMeans(t(x), w = w, na.rm = FALSE)
  > stopifnot(all.equal(x_est2, x_est1))
  > # Test with and without dimnames on x
  > for (setDimnames in c(TRUE, FALSE)) {
  +   if (setDimnames) dimnames(x) <- dimnames
  +   else dimnames(x) <- NULL    
  +   # Check names attribute
  +   for (useNames in c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)) {
  +     x_est0 <- rowWeightedMeans_R(x, w = w, na.rm = FALSE, useNames = useNames)
  +     x_est1 <- rowWeightedMeans(x, w = w, na.rm = FALSE, useNames = useNames)
  +     stopifnot(all.equal(x_est1, x_est0))
  +     x_est0 <- colWeightedMeans_R(t(x), w = w, na.rm = FALSE, useNames = useNames)
  +     x_est1 <- colWeightedMeans(t(x), w = w, na.rm = FALSE, useNames = useNames)
  +     stopifnot(all.equal(x_est1, x_est0))
  +   }
  + }
  > 
  > proc.time()
     user  system elapsed 
     0.40    0.07    0.46 
Running the tests in 'tests/rowWeightedMeans_subset.R' failed.
Complete output:
  > library("matrixStats")
  > 
  > ## Create isFALSE() if running on an old version of R
  > if (!exists("isFALSE", mode="function")) {
  +   isFALSE <- function(x) is.logical(x) && length(x) == 1L && !is.na(x) && !x
  + }
  > 
  > rowWeightedMeans_R <- function(x, w, na.rm = FALSE, ..., useNames = NA) {
  +   res <- apply(x, MARGIN = 1L, FUN = weighted.mean, w = w, na.rm = na.rm, ...)
  +   
  +   # Keep naming support consistency same as rowWeightedMeans()
  +   idxs <- which(is.na(w) | w != 0)
  +   nw <- length(idxs)
  +   if (na.rm) na.rm <- anyMissing(x)
  +   if ((!is.null(w) && nw == 0L) || isFALSE(na.rm)) {
  +     if (is.na(useNames) || !useNames) names(res) <- NULL
  +   }
  +   else if (isFALSE(useNames)) names(res) <- NULL
  +   
  +   res
  + }
  > 
  > colWeightedMeans_R <- function(x, w, na.rm = FALSE, ..., useNames = NA) {
  +   res <- apply(x, MARGIN = 1L, FUN = weighted.mean, w = w, na.rm = na.rm, ...)
  +   
  +   # Keep naming support consistency same as colWeightedMeans()
  +   idxs <- which(is.na(w) | w != 0)
  +   nw <- length(idxs)
  +   if (!is.null(w) && nw == 0L) {
  +     if (is.na(useNames) || !useNames) names(res) <- NULL
  +   }
  +   else if (isFALSE(useNames)) names(res) <- NULL
  +   
  +   res
  + }
  > 
  > 
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > # Subsetted tests
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > source("utils/validateIndicesFramework.R")
  > # To check names attribute
  > dimnames <- list(letters[1:6], LETTERS[1:6])
  > for (mode in c("numeric", "integer", "logical")) {
  +   x <- matrix(runif(6 * 6, min = -6, max = 6), nrow = 6, ncol = 6)
  +   w <- runif(6, min = 0, max = 6)
  +   storage.mode(x) <- mode
  +   storage.mode(w) <- if (mode == "logical") "integer" else mode
  +   if (mode == "numeric") w[1] <- Inf
  + 
  +   # Test with and without dimnames on x
  +   for (setDimnames in c(TRUE, FALSE)) {
  +     if (setDimnames) dimnames(x) <- dimnames
  +     else dimnames(x) <- NULL
  + 
  +     count <- 0L
  +     for (rows in index_cases) {
  +       for (cols in index_cases) {
  +         count <- count + 1L
  +         na.rm <- c(TRUE, FALSE)[count %% 2 + 1]
  +         useNames <- c(if (!matrixStats:::isUseNamesNADefunct()) NA, TRUE, FALSE)
  +         useNames <- useNames[count %% length(useNames) + 1]
  + 
  +         validateIndicesTestMatrix_w(x, w, rows, cols, 
  +                                     ftest = rowWeightedMeans, fsure = rowWeightedMeans_R,
  +                                     na.rm = na.rm, useNames = useNames)
  +         validateIndicesTestMatrix_w(x, w, rows, cols,
  +                                     fcoltest = colWeightedMeans, fsure = colWeightedMeans_R,
  +                                     na.rm = na.rm, useNames = useNames)
  +       }
  +     }
  +   }
  + }
  > 
  > proc.time()
     user  system elapsed 
     1.68    0.09    1.76 
Running the tests in 'tests/signTabulate.R' failed.
Complete output:
  > library("matrixStats")
  > 
  > signTabulate0 <- function(x, ...) {
  +   nneg <- sum(x < 0, na.rm = TRUE)
  +   nzero <- sum(x == 0, na.rm = TRUE)
  +   npos <- sum(x > 0, na.rm = TRUE)
  +   nna <- sum(is.na(x))
  +   nneginf <- sum(is.infinite(x) & x < 0, na.rm = TRUE)
  +   nposinf <- sum(is.infinite(x) & x > 0, na.rm = TRUE)
  +   res <- c(nneg, nzero, npos, nna, nneginf, nposinf)
  +   res <- as.double(res)
  +   names(res) <- c("-1", "0", "+1", "NA", "-Inf", "+Inf")
  +   if (is.integer(x)) res <- res[1:4]
  +   res
  + } # signTabulate0()
  > 
  > 
  > # Simulate data
  > set.seed(0xBEEF)
  > n <- 100L
  > x <- runif(n)
  > x[sample(n, size = 0.1 * n)] <- 0
  > x[sample(n, size = 0.1 * n)] <- NA_real_
  > x[sample(n, size = 0.1 * n)] <- -Inf
  > x[sample(n, size = 0.1 * n)] <- +Inf
  > 
  > # Doubles
  > message("Doubles:")
  Doubles:
  > counts0 <- signTabulate0(x)
  > print(counts0)
    -1    0   +1   NA -Inf +Inf 
     9    7   77    7    9   10 
  > counts1 <- signTabulate(x)
  > print(counts1)
    -1    0   +1   NA -Inf +Inf 
     9    7   77    7    9   10 
  > stopifnot(identical(counts1, counts0))
  > 
  > # Integers
  > message("Integers:")
  Integers:
  > x <- suppressWarnings(as.integer(x))
  > counts0 <- signTabulate0(x)
  > print(counts0)
  -1  0 +1 NA 
   0 74  0 26 
  > counts1 <- signTabulate(x)
  > print(counts1)
  -1  0 +1 NA 
   0 74  0 26 
  > stopifnot(identical(counts1, counts0))
  > 
  > proc.time()
     user  system elapsed 
     0.23    0.09    0.28 
Running the tests in 'tests/signTabulate_subset.R' failed.
Complete output:
  > library("matrixStats")
  > 
  > signTabulate0 <- function(x, ...) {
  +   nneg <- sum(x < 0, na.rm = TRUE)
  +   nzero <- sum(x == 0, na.rm = TRUE)
  +   npos <- sum(x > 0, na.rm = TRUE)
  +   nna <- sum(is.na(x))
  +   nneginf <- sum(is.infinite(x) & x < 0, na.rm = TRUE)
  +   nposinf <- sum(is.infinite(x) & x > 0, na.rm = TRUE)
  +   res <- c(nneg, nzero, npos, nna, nneginf, nposinf)
  +   res <- as.double(res)
  +   names(res) <- c("-1", "0", "+1", "NA", "-Inf", "+Inf")
  +   if (is.integer(x)) res <- res[1:4]
  +   res
  + } # signTabulate0()
  > 
  > 
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > # Subsetted tests
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > source("utils/validateIndicesFramework.R")
  > x <- matrix(runif(6 * 6, min = -6, max = 6), nrow = 6, ncol = 6)
  > x[2:3, 4:5] <- +Inf
  > x[4:5, 1:2] <- -Inf
  > for (idxs in index_cases) {
  +   validateIndicesTestVector(x, idxs,
  +                             ftest = signTabulate, fsure = signTabulate0)
  + }
  > 
  > proc.time()
     user  system elapsed 
     0.25    0.06    0.25 
Running the tests in 'tests/sum2_subset.R' failed.
Complete output:
  > library("matrixStats")
  > 
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > # Subsetted tests
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > source("utils/validateIndicesFramework.R")
  > x <- runif(6, min = -6, max = 6)
  > storage.mode(x) <- "integer"
  > for (idxs in index_cases) {
  +   validateIndicesTestVector(x, idxs,
  +                             ftest = sum2, fsure = sum,
  +                             na.rm = FALSE)
  +   validateIndicesTestVector(x, idxs,
  +                             ftest = sum2, fsure = sum,
  +                             na.rm = TRUE)
  + }
  > 
  > proc.time()
     user  system elapsed 
     0.28    0.06    0.28 
Running the tests in 'tests/validateIndices.R' failed.
Complete output:
  > library(matrixStats)
  > source("utils/validateIndicesFramework.R")
  > 
  > oopts <- options(matrixStats.validateIndices = "ignore")
  > 
  > ftest <- function(x, idxs) validateIndices(idxs, length(x))
  > 
  > x <- 1:6
  > for (idxs in index_cases) {
  +   for (mode in c("integer", "numeric", "logical")) {
  +     if (!is.null(idxs)) {
  +       suppressWarnings({storage.mode(idxs) <- mode})
  +     }
  +     validateIndicesTestVector(x, idxs, ftest = ftest, fsure = identity)
  +   }
  + }
  > 
  > ftest <- function(x, idxs) validateIndices(idxs, length(x))
  > 
  > for (idxs in index_error_cases) {
  +   validateIndicesTestVector(x, idxs, ftest = ftest, fsure = identity)
  + }
  > 
  > 
  > ftest <- function(x, rows, cols) {
  +   vr <- validateIndices(rows, dim(x)[1], FALSE)
  +   vc <- validateIndices(cols, dim(x)[2], FALSE)
  + 
  +   stopifnot(all((vr > 0 & vr <= dim(x)[1]) | is.na(vr)))
  +   stopifnot(all((vc > 0 & vc <= dim(x)[2]) | is.na(vc)))
  +   suppressWarnings(x <- x[vr, vc, drop = FALSE])
  +   x
  + }
  > 
  > x <- matrix(1:36, nrow = 6, ncol = 6)
  > for (rows in index_cases) {
  +   for (cols in index_cases) {
  +     validateIndicesTestMatrix(x, rows, cols, ftest = ftest, fsure = identity)
  +   }
  + }
  > 
  > # Testing for 64-bit builds (64 bits = 8 bytes)
  > if (.Machine$sizeof.pointer == 8L) {
  +   validateIndices(c(1.25*2^40, 3, 1*2^38, 1, 1.4*2^39), maxIdx = 1*2^41)
  + }
  [1] 1.374390e+12 3.000000e+00 2.748779e+11 1.000000e+00 7.696581e+11
  > 
  > options(oopts)
  > 
  > proc.time()
     user  system elapsed 
     0.42    0.06    0.46 
Running the tests in 'tests/weightedMean_subset.R' failed.
Complete output:
  > library("matrixStats")
  > 
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > # Subsetted tests
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > source("utils/validateIndicesFramework.R")
  > for (mode in c("numeric", "integer")) {
  +   x <- runif(6, min = -6, max = 6)
  +   w <- runif(6, min = 0, max = 6)
  +   storage.mode(x) <- mode
  +   storage.mode(w) <- mode
  +   if (mode == "numeric") w[1] <- Inf
  + 
  +   for (idxs in index_cases) {
  +     validateIndicesTestVector_w(x, w, idxs,
  +                                 ftest = weightedMean, fsure = weighted.mean,
  +                                 na.rm = TRUE, refine = TRUE)
  +     validateIndicesTestVector_w(x, w, idxs,
  +                                 ftest = weightedMean, fsure = weighted.mean,
  +                                 na.rm = FALSE, refine = TRUE)
  +   }
  + }
  > 
  > proc.time()
     user  system elapsed 
     0.18    0.06    0.23 
Running the tests in 'tests/weightedMedian.R' failed.
Complete output:
  > library("matrixStats")
  > 
  > x <- 1:5
  > y <- weightedMedian(x)
  > y <- weightedMedian(x, w = c(NA, Inf, NA, Inf, NA), na.rm = TRUE)
  > print(y)
  [1] 3
  > 
  > y <- weightedMedian(x, w = c(NA, Inf, NA, Inf, NA), na.rm = FALSE)
  > print(y)
  [1] NA
  > stopifnot(is.na(y))
  > 
  > x <- 1:10
  > n <- length(x)
  > 
  > y1 <- median(x)                           # 5.5
  > y2 <- weightedMedian(x)                   # 5.5
  > stopifnot(all.equal(y1, y2))
  > 
  > 
  > w <- rep(1, times = n)
  > y1 <- weightedMedian(x, w)                 # 5.5 (default)
  > y2a <- weightedMedian(x, ties = "weighted")  # 5.5 (default)
  > y2b <- weightedMedian(x, ties = "min")       # 5
  > y2c <- weightedMedian(x, ties = "max")       # 6
  > stopifnot(all.equal(y2a, y1))
  > 
  > y3 <- weightedMedian(x, w)                # 5.5 (default)
  > 
  > 
  > # Pull the median towards zero
  > w[1] <- 5
  > y1 <- weightedMedian(x, w)                # 3.5
  > y <- c(rep(0, times = w[1]), x[-1])       # Only possible for integer weights
  > y2 <- median(y)                           # 3.5
  > stopifnot(all.equal(y1, y2))
  > 
  > # Put even more weight on the zero
  > w[1] <- 8.5
  > y <- weightedMedian(x, w)                # 2
  > 
  > # All weight on the first value
  > w[1] <- Inf
  > y <- weightedMedian(x, w)                # 1
  > 
  > # All weight on the last value
  > w[1] <- 1
  > w[n] <- Inf
  > y <- weightedMedian(x, w)                # 10
  > 
  > # All weights set to zero
  > w <- rep(0, times = n)
  > y <- weightedMedian(x, w)                # NA
  > 
  > x <- 1:4
  > w <- rep(1, times = 4)
  > for (mode in c("integer", "double")) {
  +   storage.mode(x) <- mode
  +   for (ties in c("weighted", "mean", "min", "max")) {
  +     cat(sprintf("ties = %s\n", ties))
  +     y <- weightedMedian(x, w, ties = ties)
  +   }
  + }
  ties = weighted
  ties = mean
  ties = min
  ties = max
  ties = weighted
  ties = mean
  ties = min
  ties = max
  > 
  > set.seed(0x42)
  > 
  > y <- weightedMedian(x = double(0L))
  > print(y)
  [1] NA
  > stopifnot(length(y) == 1L)
  > stopifnot(is.na(y))
  > 
  > y <- weightedMedian(x = x[1])
  > print(y)
  [1] 1
  > stopifnot(length(y) == 1L)
  > stopifnot(all.equal(y, x[1]))
  > 
  > 
  > n <- 1e3
  > x <- runif(n)
  > w <- runif(n, min = 0, max = 1)
  > for (mode in c("integer", "double")) {
  +   storage.mode(x) <- mode
  +   for (ties in c("weighted", "mean", "min", "max")) {
  +     y <- weightedMedian(x, w, ties = ties)
  +     cat(sprintf("mode = %s, ties = %s, result = %g\n", mode, ties, y))
  +   }
  + }
  mode = integer, ties = weighted, result = 0
  mode = integer, ties = mean, result = 0
  mode = integer, ties = min, result = 0
  mode = integer, ties = max, result = 0
  mode = double, ties = weighted, result = 0
  mode = double, ties = mean, result = 0
  mode = double, ties = min, result = 0
  mode = double, ties = max, result = 0
  > 
  > 
  > # A large vector
  > n <- 1e5
  > x <- runif(n)
  > w <- runif(n, min = 0, max = 1)
  > y <- weightedMedian(x, w)
  > 
  > y <- weightedMedian(x, w, ties = "min")
  > 
  > 
  > # Single Number
  > xs <- c(1, NA_integer_)
  > ws <- c(1, NA_integer_)
  > for (x in xs) {
  +   for (w in ws) {
  +     y <- weightedMedian(x = x, w = w)
  +     if (is.na(w)) z <- NA_real_
  +     else z <- x[1]
  +     stopifnot(all.equal(y, z))
  +   }
  + }
  > 
  > ## Logical
  > x1 <- c(TRUE, FALSE, TRUE)
  > w0 <- c(0, 0, 0)
  > stopifnot(!is.finite(weightedMedian(x1, w0)),
  +           !is.infinite(weightedMedian(x1, w0)))
  > 
  > w1 <- c(1, 1, 1)
  > stopifnot(weightedMedian(x1, w1) == 1)
  > 
  > w2 <- c(1, 2, 3)
  > stopifnot(weightedMedian(x1, w2) == 1)
  > 
  > ### NA
  > stopifnot(is.na(weightedMedian(c(TRUE, FALSE, NA),
  +                                c(1, 2, 3))),
  +           all.equal(weightedMedian(c(TRUE, FALSE, NA),
  +                                    c(1, 2, 3),
  +                                    na.rm = TRUE),
  +                     weightedMedian(c(TRUE, FALSE),
  +                                    c(1, 2))))
  > ### Identical to as.integer()
  > x <- rcauchy(100)
  > w <- abs(rcauchy(100))
  > stopifnot(all.equal(weightedMedian(x > 0, w),
  +                     weightedMedian(as.integer(x > 0), w)))
  > 
  > 
  > 
  > proc.time()
     user  system elapsed 
     0.29    0.03    0.32 
Running the tests in 'tests/weightedMedian_subset.R' failed.
Complete output:
  > library("matrixStats")
  > 
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > # Subsetted tests
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > source("utils/validateIndicesFramework.R")
  > for (mode in c("numeric", "integer")) {
  +   x <- runif(6, min = -6, max = 6)
  +   w <- runif(6, min = 0, max = 6)
  +   storage.mode(x) <- mode
  +   storage.mode(w) <- mode
  +   if (mode == "numeric") w[1] <- Inf
  + 
  +   for (idxs in index_cases) {
  +     validateIndicesTestVector_w(x, w, idxs,
  +                                 ftest = weightedMedian,
  +                                 fsure = weightedMedian,
  +                                 na.rm = TRUE)
  +     validateIndicesTestVector_w(x, w, idxs,
  +                                 ftest = weightedMedian,
  +                                 fsure = weightedMedian,
  +                                 na.rm = FALSE)
  + 
  +     for (ties in c("weighted", "mean", "min", "max")) {
  +       validateIndicesTestVector_w(x, w, idxs,
  +                                   ftest = weightedMedian,
  +                                   fsure = weightedMedian,
  +                                   na.rm = TRUE, ties = ties)
  +       validateIndicesTestVector_w(x, w, idxs,
  +                                   ftest = weightedMedian,
  +                                   fsure = weightedMedian,
  +                                   na.rm = FALSE, ties = ties)
  +     }
  +   }
  + }
  > 
  > proc.time()
     user  system elapsed 
     0.31    0.04    0.34 
Running the tests in 'tests/weightedVar.R' failed.
Complete output:
  > library("matrixStats")
  > 
  > weightedVar_R <- function(x, w) {
  +   mu <- weighted.mean(x, w = w)
  +   sum(w * (x - mu) ^ 2) / (sum(w) - 1)
  + }
  > 
  > 
  > n <- 10
  > x <- as.double(1:n)
  > 
  > message("*** weightedVar() ...")
  *** weightedVar() ...
  > 
  > message("- Zero elements")
  - Zero elements
  > m0 <- var(integer(0))
  > m1 <- weightedVar(integer(0), w = integer(0))
  > str(list(m0 = m0, m1 = m1))
  List of 2
   $ m0: num NA
   $ m1: int NA
  > stopifnot(all.equal(m1, m0))
  > 
  > 
  > message("- One elements")
  - One elements
  > m0 <- var(1)
  > m1 <- weightedVar(1)
  > str(list(m0 = m0, m1 = m1))
  List of 2
   $ m0: num NA
   $ m1: num NA
  > stopifnot(all.equal(m1, m0))
  > 
  > 
  > message("- Uniform weights (all w = 1)")
  - Uniform weights (all w = 1)
  > m0 <- var(x)
  > w <- rep(1, times = n)
  > m1 <- weightedVar(x, w = w)
  > str(list(m0 = m0, m1 = m1))
  List of 2
   $ m0: num 9.17
   $ m1: num 9.17
  > stopifnot(all.equal(m1, m0))
  > 
  > 
  > message("- Uniform weights (all w = 3)")
  - Uniform weights (all w = 3)
  > m0 <- var(rep(x, each = 3))
  > w <- rep(3, times = n)
  > m1 <- weightedVar(x, w = w)
  > str(list(m0 = m0, m1 = m1))
  List of 2
   $ m0: num 8.53
   $ m1: num 8.53
  > stopifnot(all.equal(m1, m0))
  > 
  > 
  > message("- Uniform weights on the first five elements")
  - Uniform weights on the first five elements
  > idxs <- 1:5
  > m0 <- var(x[1:5])
  > w <- rep(0, times = n)
  > w[idxs] <- 1
  > m1 <- weightedVar(x, w = w)
  > str(list(m0 = m0, m1 = m1))
  List of 2
   $ m0: num 2.5
   $ m1: num 2.5
  > stopifnot(all.equal(m1, m0))
  > 
  > 
  > message("- Uniform weights on every second elements")
  - Uniform weights on every second elements
  > idxs <- seq(from = 1, to = n, by = 2)
  > m0 <- var(x[idxs])
  > w <- rep(0, times = n)
  > w[idxs] <- 1
  > m1 <- weightedVar(x, w = w)
  > str(list(m0 = m0, m1 = m1))
  List of 2
   $ m0: num 10
   $ m1: num 10
  > stopifnot(all.equal(m1, m0))
  > 
  > 
  > message("- All weights are zero")
  - All weights are zero
  > idxs <- integer(0L)
  > m0 <- var(x[idxs])
  > w <- rep(0, times = n)
  > w[idxs] <- 1
  > m1 <- weightedVar(x, w = w)
  > str(list(m0 = m0, m1 = m1))
  List of 2
   $ m0: num NA
   $ m1: num NA
  > stopifnot(all.equal(m1, m0))
  > 
  > message("- Infinite weight on first element")
  - Infinite weight on first element
  > idxs <- 1L
  > m0 <- var(x[idxs])
  > w <- rep(0, times = n)
  > w[idxs] <- Inf
  > m1 <- weightedVar(x, w = w)
  > str(list(m0 = m0, m1 = m1))
  List of 2
   $ m0: num NA
   $ m1: num NA
  > stopifnot(all.equal(m1, m0))
  > 
  > message("- Missing-value weight on first element")
  - Missing-value weight on first element
  > idxs <- 1L
  > w <- rep(1, times = n)
  > w[idxs] <- NA_real_
  > m1 <- weightedVar(x, w = w)
  > str(list(m1 = m1))
  List of 1
   $ m1: num NA
  > stopifnot(identical(m1, NA_real_))
  > 
  > 
  > message("- Frequency weights")
  - Frequency weights
  > 
  > ## From https://en.wikipedia.org/wiki/Weighted_arithmetic_mean
  > y <-  c(2, 2, 4, 5, 5, 5)
  > x <- unique(y)
  > w <- table(y)
  > stopifnot(names(w) == x)
  > 
  > m0 <- weightedVar(x, w = w)
  > m1 <- var(y)
  > stopifnot(all.equal(m1, m0))
  > m2 <- weightedVar(x, w = w)
  > str(list(m0 = m0, m1 = m1, m2 = m2))
  List of 3
   $ m0: num 2.17
   $ m1: num 2.17
   $ m2: num 2.17
  > stopifnot(all.equal(m2, m0))
  > 
  > ## From https://github.com/HenrikBengtsson/matrixStats/issues/72
  > large <- c(21, 8, 26, 1, 15, 33, 12, 25, 0, 84)
  > years <- c(41706, 9301, 33678, 3082, 27040, 44188, 10049, 30591, 2275, 109831)
  > 
  > m0 <- weightedVar(large, w = years)
  > m1 <- weightedVar(large, w = years)
  > str(list(m0 = m0, m1 = m1))
  List of 2
   $ m0: num 899
   $ m1: num 899
  > stopifnot(all.equal(m1, m0))
  > 
  > message("*** weightedVar() ... DONE")
  *** weightedVar() ... DONE
  > 
  > proc.time()
     user  system elapsed 
     0.10    0.12    0.21 
Running the tests in 'tests/weightedVar_etal_subset.R' failed.
Complete output:
  > library("matrixStats")
  > 
  > fcns <- list(
  +   weightedVar = weightedVar,
  +   weightedSd  = weightedSd,
  +   weightedMad = weightedMad
  + )
  > 
  > 
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > # Subsetted tests
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > source("utils/validateIndicesFramework.R")
  > for (name in names(fcns)) {
  +   cat(sprintf("subsetted tests on %s()...\n", name))
  +   fcn <- fcns[[name]]
  + 
  +   for (mode in c("numeric", "integer")) {
  +     x <- runif(6, min = -6, max = 6)
  +     w <- runif(6, min = 0, max = 6)
  +     storage.mode(x) <- mode
  +     storage.mode(w) <- mode
  +     if (mode == "numeric") w[1] <- Inf
  + 
  +     for (idxs in index_cases) {
  +       validateIndicesTestVector_w(x, w, idxs,
  +                                   ftest = fcn, fsure = fcn,
  +                                   na.rm = TRUE)
  +       validateIndicesTestVector_w(x, w, idxs,
  +                                   ftest = fcn, fsure = fcn,
  +                                   na.rm = FALSE)
  +     }
  +   }
  +   cat(sprintf("%s()...DONE\n", name))
  + }
  subsetted tests on weightedVar()...
  weightedVar()...DONE
  subsetted tests on weightedSd()...
  weightedSd()...DONE
  subsetted tests on weightedMad()...
  weightedMad()...DONE
  > 
  > proc.time()
     user  system elapsed 
     0.25    0.04    0.28 
Running the tests in 'tests/x_OP_y_subset.R' failed.
Complete output:
  > library("matrixStats")
  > 
  > x_OP_y_R <- function(x, y, OP, na.rm = FALSE) {
  +   if (na.rm) {
  +     xnok <- is.na(x)
  +     ynok <- is.na(y)
  +     anok <- xnok & ynok
  +     unit <- switch(OP,
  +       "+" = 0,
  +       "-" = NA_real_,
  +       "*" = 1,
  +       "/" = NA_real_,
  +       stop("Unknown 'OP' operator: ", OP)
  +     )
  +     x[xnok] <- unit
  +     y[ynok] <- unit
  +   }
  + 
  +   ans <- switch(OP,
  +     "+" = x + y,
  +     "-" = x - y,
  +     "*" = x * y,
  +     "/" = x / y,
  +     stop("Unknown 'OP' operator: ", OP)
  +   )
  + 
  +   if (na.rm) {
  +     ans[anok] <- NA_real_
  +   }
  + 
  +   ans
  + } # x_OP_y_R()
  > 
  > 
  > t_tx_OP_y_R <- function(x, y, OP, na.rm = FALSE) {
  +   t(x_OP_y_R(x = t(x), y = y, OP = OP, na.rm = na.rm))
  + }
  > 
  > 
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > # Subsetted tests
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > source("utils/validateIndicesFramework.R")
  > for (OP in c("+", "-", "*", "/")) {
  +   for (mode in c("numeric", "integer", "logical")) {
  +     x <- matrix(runif(6 * 6, min = -6, max = 6), nrow = 6L, ncol = 6L)
  +     y <- runif(6, min = 0, max = 6)
  +     storage.mode(x) <- mode
  +     storage.mode(y) <- mode
  +     if (mode == "numeric") y[1] <- Inf
  + 
  +     for (xrows in index_cases) {
  +       for (xcols in index_cases) {
  +         if (is.null(xrows)) xrows <- seq_len(nrow(x))
  +         if (is.null(xcols)) xcols <- seq_len(ncol(x))
  + 
  +         for (yidxs in list(xrows, xcols)) {
  +           for (na.rm in c(TRUE, FALSE)) {
  + 
  +             suppressWarnings({
  +               actual <- tryCatch(
  +                 x_OP_y(x, y, OP, xrows = xrows, xcols = xcols, yidxs = yidxs,
  +                        na.rm = na.rm),
  +                 error = function(c) "error"
  +               )
  + 
  +               expect <- tryCatch(
  +                 x_OP_y_R(x[xrows, xcols, drop = FALSE], y[yidxs], OP,
  +                          na.rm = na.rm),
  +                 error = function(c) "error"
  +               )
  +             })
  +             stopifnot(all.equal(as.vector(actual), as.vector(expect)))
  + 
  +             suppressWarnings({
  +               actual <- tryCatch(
  +                 t_tx_OP_y(x, y, OP, xrows = xrows, xcols = xcols, yidxs = yidxs,
  +                           na.rm = na.rm),
  +                 error = function(c) "error"
  +               )
  + 
  +               expect <- tryCatch(
  +                 t_tx_OP_y_R(x[xrows, xcols, drop = FALSE], y[yidxs], OP,
  +                             na.rm = na.rm),
  +                 error = function(c) "error"
  +               )
  +             })
  +             stopifnot(all.equal(as.vector(actual), as.vector(expect)))
  +           }
  +         }
  +       }
  +     }
  +   }
  + }
  > 
  > proc.time()
     user  system elapsed 
     6.53    0.17    6.68 
Running the tests in 'tests/zzz.package-unload.R' failed.
Complete output:
  > ## These tests need to be last of all tests, otherwise
  > ## covr::package_coverage() gives an error.
  > cat("1. Loading package\n")
  1. Loading package
  > loadNamespace("matrixStats")
  <environment: namespace:matrixStats>
  > stopifnot("matrixStats" %in% loadedNamespaces())
  > 
  > cat("2. Unloading package\n")
  2. Unloading package
  > unloadNamespace("matrixStats")
  > stopifnot(!"matrixStats" %in% loadedNamespaces())
  > 
  > if (FALSE) {
  +   ## 'covr' gives "Error in library("matrixStats") :
  +   ## there is no package called 'matrixStats'" here, cf.
  +   ## https://travis-ci.org/HenrikBengtsson/matrixStats/builds/48015577
  + 
  +   cat("3. Attaching package\n")
  +   library("matrixStats")
  +   stopifnot("package:matrixStats" %in% search())
  + 
  +   cat("4. Detaching package\n")
  +   detach("package:matrixStats")
  +   stopifnot(!"package:matrixStats" %in% search())
  +   stopifnot("matrixStats" %in% loadedNamespaces())
  + 
  +   cat("5. Unloading package\n")
  +   unloadNamespace("matrixStats")
  +   stopifnot(!"matrixStats" %in% loadedNamespaces())
  + 
  +   cat("6. Attaching package (again)\n")
  +   library("matrixStats")
  +   stopifnot("package:matrixStats" %in% search())
  + 
  +   cat("7. Detaching package (again)\n")
  +   detach("package:matrixStats")
  +   stopifnot(!"package:matrixStats" %in% search())
  +   stopifnot("matrixStats" %in% loadedNamespaces())
  + }
  > 
  > cat("7. DONE\n")
  7. DONE
  > 
  > proc.time()
     user  system elapsed 
     0.18    0.04    0.21