makeNRedMatr | R Documentation |
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).
makeNRedMatr(
dat,
summarizeRedAs,
iniID = "iniID",
retDataFrame = TRUE,
silent = FALSE,
debug = FALSE,
callFrom = NULL
)
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") |
retDataFrame |
(logical) if TRUE, check if text-columns may be converted to data.frame with numeric |
silent |
(logical) suppress messages |
debug |
(logical) for bug-tracking: more/enhanced messages |
callFrom |
(character) allows easier tracking of message(s) produced |
This function returns a (numeric) matrix or data.frame with summarized data and add'l col with number of initial redundant lines
simple/partial functionality in summarizeCols
, checkSimValueInSer
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"))
(xt3 <- makeNRedMatr(t3, summ="mean", iniID="ref"))
(xt3 <- makeNRedMatr(t3, summ=unlist(list(X1="maxAbsOfRef")), iniID="ref"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.