summarizeCols {wrMisc}R Documentation

Summarize columns (as median,mean,min,last or other methods)

Description

summarizeCols summarizes all columns of matrix (or data.frame). In case of text-columns the sorted middle (~median) will be given, unless 'maxAbsLast', 'minAbsLast', .. consider only last column of 'matr' : choose from all columns the line where (max of) last col is at min; 'medianComplete' or 'meanComplete' consideres only lines/rows where no NA occur (NA have influence other columns !)

Usage

summarizeCols(
  matr,
  meth = "median",
  refCol = NULL,
  nEqu = FALSE,
  silent = FALSE,
  debug = FALSE,
  callFrom = NULL
)

Arguments

matr

data.frame matrix of data to be summarized by comlumn (may do different method for text and numeric comlumns)

meth

(character) summarization method (eg 'min','max','mean','aver','median','first','last','maxOfRef','minOfRef','maxAbsLast','minAbsLast', 'medianComplete' or 'meanComplete')

refCol

(character or integr) column to be used as reference

nEqu

(logical) if TRUE, add additional column indicating the number of equal lines for choice (only with min or max)

silent

(logical) suppress messages

debug

(logical) additional messages for debugging

callFrom

(character) allow easier tracking of messages produced

Details

The argument method allows options that treat (summarize) all columns independently or to select one line (based on argulent refCol)

Value

vector with summary for each column

See Also

rowMeans in colSums; if data has subgroups to be used in a tapply()-way please see makeNRedMatr

Examples

t1 <- matrix(round(runif(30,1,9)), nc=3); rownames(t1) <- letters[c(1:5,3:4,6:4)]
summarizeCols(t1, me="median")
t(sapply(by(t1,rownames(t1), function(x) x), summarizeCols,me="maxAbsLast"))
t3 <- data.frame(ref=rep(11:15,3), tx=letters[1:15],
  matrix(round(runif(30,-3,2),1), ncol=2), stringsAsFactors=FALSE)
by(t3,t3[,1], function(x) x)
by(t3,t3[,1], function(x) summarizeCols(x, me="maxAbsLast"))
t(sapply(by(t3,t3[,1], function(x) x), summarizeCols, me="maxAbsLast"))

[Package wrMisc version 1.15.1 Index]