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

View source: R/summarizeCols.R

summarizeColsR 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,
  supl = NULL,
  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, may be 'mean','aver','median','sd','CV', 'min','max','first','last','maxOfRef','minOfRef','maxAbsLast','minAbsLast', 'medianComplete' or 'meanComplete', 'n' (number of non-NA elements),'n.NA' (number of NA elements), 'NULL' (returns NULL)

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)

supl

(numeric) supplemental parameters for the various summarizing functions (eg used with meth="trimmedMean", supl=c(l=0.1,u=0.2) to pass arguments to trimmedMean)

silent

(logical) suppress messages

debug

(logical) additional messages for debugging

callFrom

(character) allows easier tracking of messages produced

Details

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

Value

vector with summary for each column

See Also

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"))

wrMisc documentation built on Sept. 11, 2024, 6:10 p.m.