R Under development (unstable) (2023-11-06 r85483 ucrt) -- "Unsuffered Consequences" Copyright (C) 2023 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > library("matrixStats") > > 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() > > > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - > # 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]) > > probs <- 0.3 > # 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)) { + if (is.null(cols)) which <- round(probs * ncol(x)) + else { + xxrows <- rows + suppressWarnings({ + xx <- tryCatch(x[, cols, drop = FALSE], error = function(c) "error") + if (identical(xx, "error")) which <- 0L + else which <- round(probs * ncol(xx)) + }) + } + if (which == 0L) next + + validateIndicesTestMatrix(x, rows, cols, + ftest = rowOrderStats, fsure = rowOrderStats_R, + which = which, probs = probs, useNames = useNames) + validateIndicesTestMatrix(x, rows, cols, + fcoltest = colOrderStats, fsure = rowOrderStats_R, + which = which, probs = probs, useNames = useNames) + } + } + } + } > > proc.time() user system elapsed 1.21 0.04 1.25