makeNRedMatr {wrMisc} | R Documentation |
Make non-redundant matrix
Description
makeNRedMatr
takes matrix or data.frame 'dat' to summarize redundant lines (column argument iniID
) along method specified in summarizeRedAs
to treat all lines with redundant iniID
by same approach (ie for all columns the line where specified column is at eg max = 'maxOfRef' ).
If no name given, the function will take the last numeric (factors may be used - they will be read as levels).
Usage
makeNRedMatr(
dat,
summarizeRedAs,
iniID = "iniID",
retDataFrame = TRUE,
nEqu = FALSE,
silent = FALSE,
debug = FALSE,
callFrom = NULL
)
Arguments
dat |
(matrix or data.frame) main input for making non-redundant |
summarizeRedAs |
(character) summarization method(s), typical choices 'median','mean','min' or 'maxOfRef', 'maxAbsOfRef' for summarizing according to 1 specified column, may be single method for all or different method for each column (besides col 'iniID') or special method looking at column (if found, first of special methods used, everything else not considered). |
iniID |
(character) column-name used as initial ID (default="iniID"), ie reference for determining groups of redundant lines |
retDataFrame |
(logical) if |
nEqu |
(logical) if |
silent |
(logical) suppress messages |
debug |
(logical) additional messages for debugging |
callFrom |
(character) allows easier tracking of messages produced |
Details
When using for selection of single initial line give the character-string of argument summarizeRedAs
a name (eg summ=c(X1="minOfRef")
so that the function will use ONLY the column specified via the name for determining which line should be used/kept.
This function has been developed using Proline version 1.6.1 coupled with MS-Angel 1.6.1.
Value
This function returns a (numeric) matrix or data.frame with summarized data and add'l col with number of initial redundant lines
See Also
simple/partial functionality in summarizeCols
, checkSimValueInSer
Examples
t3 <- data.frame(ref=rep(11:15,3),tx=letters[1:15],
matrix(round(runif(30,-3,2),1),nc=2),stringsAsFactors=FALSE)
by(t3,t3[,1],function(x) x)
t(sapply(by(t3,t3[,1],function(x) x), summarizeCols, me="maxAbsOfRef"))
# calculate mean for lines concerened of all columns :
(xt3 <- makeNRedMatr(t3, summ="mean", iniID="ref"))
# choose lines based only on content of column 'X1' (here: max):
(xt3 <- makeNRedMatr(t3, summ=c(X1="maxOfRef"), iniID="ref"))