R/get_rows_by_names.R

#' Get Row of Matrix by Rowname
#'
#' This function provides a pipe friendly way of retrieving rows of a matrix
#' by rownames.
#'
#' @param in.mat The input matrix
#' @param in.row.names The row names to subset by
#' @return A subset of the matrix
#' @export
#' @examples 
#' mat <- matrix(1:20, 5, 4, dimnames = list(LETTERS[1:5], NULL))
#' get_rows_by_names(mat, c("A", "D", "E"))
get_rows_by_names <- function(in.mat, in.row.names) {
  in.mat[in.row.names, ]
}
tinyheero/tinyutils documentation built on May 31, 2019, 3:36 p.m.