R/returnSlots.R

Defines functions returnSlots

Documented in returnSlots

#' returnSlots - a helper function to return slots to place in the table1
#'  
#' This function returns the slots generated by returnFactorSlots and returnNumSlots
#' @param eSet - the eSet or data.frame sent to table1
#' @param groupChar - a factor column present in eSet by which to group samples and summarize char
#' @param group - which factor level from groupChar is summarized
#' @param char - which characteristic is summarized from eSet
#' @param func - a user defined function that will also return a character summary - not really implemented yet
#' @export
#' @examples
#' returnNumSlots(eSet, "CancerStatus", "CancerPositive", "Age")

returnSlots <- function(eSet, groupChar, group, char, func=NULL){
  if(is.null(func)){
    if(is.factor(eSet[[char]])){
      return(returnFactorSlots(eSet, groupChar, group, char))
    } else if(is.numeric(eSet[[char]])){
      return(returnNumSlots(eSet, groupChar, group, char))
    }
  } else{
    return(func(eSet, groupChar, group, char))
  }
}
compbiomed/tableONE documentation built on May 13, 2019, 9:55 p.m.