R/process_counts.R

Defines functions process_counts

Documented in process_counts

#' @title Process counts
#'
#' @description Converts data in a table-like formats into lists of counts.
#' @param x \code{data.frame} or \code{matrix}. 
#' @examples
#' data(case_study)
#' process_counts(case_study)
#' @details \code{case_study} does not consider \code{NA}s and \code{NaN}s effectively 
#' omitting them (as per the \code{\link[base]{is.na}} function).
#' @return A \code{list} of counts.
#' @export
process_counts <- function(x) {
  count_list <- lapply(1L:ncol(x), function(single_column) as.vector(na.omit(x[, single_column])))
  names(count_list) <- colnames(x)
  count_list
}

Try the countfitteR package in your browser

Any scripts or data that you put into this service are public.

countfitteR documentation built on Oct. 23, 2020, 5:11 p.m.