R/untab.R

Defines functions untab

Documented in untab

#' untab: Convert Table To Array
#'
#' function to convert a table object to an array object
#'
#' Table objects tend to get automatically converted into data.frames by
#' functions.  These data.frames contain columns with factor levels and
#' frequencies that get in the way.  as.array() doesn't do anything to tables,
#' because tables are already arrays.  This function gets around these issues.
#' 
#' @param a.table
#'        an object of class table, such as generated by the table() or
#'        xtab() functions
#'        
#' @return
#'    Returns an array with the same dimensions and dimnames as a.table, that is
#'    NOT a table object, and may thus be manipulated like an array.
#'
#' @author M.W.Rowe, \email{mwr.stats@gmail.com}
#' @export
untab <-
function(a.table){
   return(array(a.table, dim=dim(a.table), dimnames=dimnames(a.table)))
}
mwrowe/microRutils documentation built on June 12, 2021, 2:41 p.m.