R/utils_subset.R

Defines functions .col_subset_to_index .row_subset_to_index

#' @importFrom S4Vectors normalizeSingleBracketSubscript
.row_subset_to_index <- function(x, index) {
    if (is.null(index)) {
        seq_len(nrow(x))
    } else {
        normalizeSingleBracketSubscript(index, x)
    }
}

.col_subset_to_index <- function(x, index) {
    if (is.null(index)) {
        seq_len(ncol(x))
    } else {
        i <- seq_len(ncol(x))
        names(i) <- colnames(x)
        unname(i[index])
    }
}
LTLA/batchelor documentation built on Jan. 19, 2024, 6:33 p.m.