rowGroupMeans | R Documentation |
Calculate row group means, or other statistics, where: rowGroupMeans()
calculates row summary stats; and rowGroupRmOutliers()
is a convenience
function to call rowGroupMeans(..., rmOutliers=TRUE, returnType="input")
.
rowGroupMeans(
x,
groups,
na.rm = TRUE,
useMedian = TRUE,
rmOutliers = FALSE,
crossGroupMad = TRUE,
madFactor = 5,
returnType = c("output", "input"),
rowStatsFunc = NULL,
groupOrder = c("same", "sort"),
keepNULLlevels = FALSE,
includeAttributes = FALSE,
verbose = FALSE,
...
)
rowGroupRmOutliers(
x,
groups,
na.rm = TRUE,
rmOutliers = TRUE,
crossGroupMad = TRUE,
madFactor = 5,
returnType = c("input"),
groupOrder = c("same", "sort"),
keepNULLlevels = FALSE,
includeAttributes = FALSE,
verbose = FALSE,
...
)
x |
|
groups |
|
useMedian |
|
rmOutliers |
|
crossGroupMad |
|
madFactor |
|
returnType |
|
rowStatsFunc |
optional |
groupOrder |
|
keepNULLlevels |
|
includeAttributes |
|
verbose |
|
... |
additional parameters are passed to |
This function by default calculates group mean values per row in a numeric matrix. However, the stat function can be changed to calculate row medians, row MADs, etc.
An added purpose of this function is optional outlier
filtering, via calculation of MAD values and applying
a MAD threshold cutoff. The intention is to identify
technical outliers that otherwise adversely affect the
calculated group mean or median values. To inspect the
data after outlier removal, use the parameter returnType="input"
which will return the input data matrix with NA
substituted for outlier points. Outlier detection and
removal is performed by jamba::rowRmMadOutliers()
.
When returnType="output"
the output is a numeric matrix
with the same number of columns as the number of unique
groups
labels. When groups
is a factor and
keepNULLlevels=TRUE
, the number of columns will be the
number of factor levels, otherwise it will be the number of
factor levels used in groups
.
When returnType="input"
the output is a numeric matrix
with the same dimensions as the input data. This output is
intended for use with rmOutliers=TRUE
which will replace
outlier points with NA
values. Therefore, this matrix can
be used to see the location of outliers.
The function also returns attributes that describe the number of samples per group overall:
The attribute "n"
is used to describe
the number of replicates per group.
The attribute "nLabel"
is
a simple text label in the form "n=3"
.
Note that when rmOutliers=TRUE
the number of replicates per
group will vary depending upon the outliers removed. In that
case, remember that the reported "n"
is always the total
possible columns available prior to outlier removal.
Other jam numeric functions:
deg2rad()
,
fix_matrix_ratio()
,
noiseFloor()
,
normScale()
,
rad2deg()
,
rowRmMadOutliers()
,
warpAroundZero()
x <- matrix(ncol=9, rnorm(90));
colnames(x) <- LETTERS[1:9];
rowGroupMeans(x, groups=rep(letters[1:3], each=3))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.