R Under development (unstable) (2023-12-09 r85665 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") > > rowMedians_R <- function(x, na.rm = FALSE, ..., useNames = NA) { + res <- apply(x, MARGIN = 1L, FUN = median, na.rm = na.rm) + if (is.na(useNames) || !useNames) names(res) <- NULL + res + } > > colMedians_R <- function(x, na.rm = FALSE, ..., useNames = NA) { + res <- apply(x, MARGIN = 2L, FUN = median, 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 = -3, max = 3), 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 = rowMedians, fsure = rowMedians_R, + na.rm = na.rm, useNames = useNames) + validateIndicesTestMatrix(x, rows, cols, + fcoltest = colMedians, fsure = rowMedians_R, + na.rm = na.rm, useNames = useNames) + } + } + } > > proc.time() user system elapsed 0.54 0.03 0.56