1library("matrixStats") 2 3signTabulate0 <- function(x, ...) { 4 nneg <- sum(x < 0, na.rm = TRUE) 5 nzero <- sum(x == 0, na.rm = TRUE) 6 npos <- sum(x > 0, na.rm = TRUE) 7 nna <- sum(is.na(x)) 8 nneginf <- sum(is.infinite(x) & x < 0, na.rm = TRUE) 9 nposinf <- sum(is.infinite(x) & x > 0, na.rm = TRUE) 10 res <- c(nneg, nzero, npos, nna, nneginf, nposinf) 11 res <- as.double(res) 12 names(res) <- c("-1", "0", "+1", "NA", "-Inf", "+Inf") 13 if (is.integer(x)) res <- res[1:4] 14 res 15} # signTabulate0() 16 17 18# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 19# Subsetted tests 20# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 21source("utils/validateIndicesFramework.R") 22x <- matrix(runif(6 * 6, min = -6, max = 6), nrow = 6, ncol = 6) 23x[2:3, 4:5] <- +Inf 24x[4:5, 1:2] <- -Inf 25for (idxs in index_cases) { 26 validateIndicesTestVector(x, idxs, 27 ftest = signTabulate, fsure = signTabulate0) 28} 29