R/rm_0s_by_col.R

Defines functions rm_0s_by_col

Documented in rm_0s_by_col

#' remove zeros vertically /w colsums
#'
#' @param col matrix column
#'
#' @return a matrix with occupied columns
#' @export
#'
#' @examples
#' set.seed(123)
#' x = matrix(rpois(100, .1), 10, 10)
#' rm_0s_by_col(x)
rm_0s_by_col<-function(col){
  output<- col[ ,colSums(col)>0]
  return(output)
}
Deebee33/N0 documentation built on Dec. 17, 2021, 4:11 p.m.