split_reduce | R Documentation |
This function summarizes subsets of a numeric matrix or matrix-like object by first splitting the object by row and then applying a summary function.
Implementation of split_reduce for matrix with integer factors.
See split_reduce
for the generic definition and complete documentation.
Implementation of split_reduce for matrix with factor grouping.
See split_reduce
for the generic definition and complete documentation.
Implementation of split_reduce for matrix with factor grouping.
See split_reduce
for the generic definition and complete documentation.
Implementation of split_reduce for NeuroVec objects.
See split_reduce
for the generic definition and complete documentation.
Implementation of split_reduce for NeuroVec objects.
See split_reduce
for the generic definition and complete documentation.
split_reduce(x, fac, FUN)
## S4 method for signature 'matrix,integer,function'
split_reduce(x, fac, FUN)
## S4 method for signature 'matrix,factor,missing'
split_reduce(x, fac)
## S4 method for signature 'matrix,factor,function'
split_reduce(x, fac, FUN)
## S4 method for signature 'NeuroVec,factor,function'
split_reduce(x, fac, FUN)
## S4 method for signature 'NeuroVec,factor,missing'
split_reduce(x, fac, FUN)
x |
A NeuroVec object |
fac |
Factor for grouping |
FUN |
Function to apply to each group |
If 'FUN' is supplied, it must take a vector and return a single scalar value. If it returns more than one value, an error will occur.
If 'x' is a NeuroVec instance, voxels (dimensions 1:3) are treated as columns and time-series (dimension 4) as rows. The summary function is then applied to groups of voxels. However, if the goal is to apply a function to groups of time-points.
This method supports two types of splitting:
By voxel: when length(fac) equals number of voxels
By volume: when length(fac) equals number of volumes
This method supports two types of splitting:
By voxel: when length(fac) equals number of voxels
By volume: when length(fac) equals number of volumes
A new matrix where the original values have been "reduced" by the supplied function.
Matrix of reduced values
Matrix of reduced values
Matrix of reduced values
Matrix of reduced values
Matrix of reduced values
split_reduce
split_reduce
split_reduce
split_reduce
split_reduce
mat = matrix(rnorm(100*100), 100, 100)
fac = factor(sample(1:3, nrow(mat), replace=TRUE))
## Compute column means of each sub-matrix
ms <- split_reduce(mat, fac)
all.equal(row.names(ms), levels(fac))
## Compute column medians of each sub-matrix
ms <- split_reduce(mat, fac, median)
## Compute time-series means grouped over voxels.
## Here, 'length(fac)' must equal the number of voxels: 'prod(dim(bvec)[1:3])'
bvec <- NeuroVec(array(rnorm(24*24*24*24), c(24,24,24,24)), NeuroSpace(c(24,24,24,24), c(1,1,1)))
fac <- factor(sample(1:3, prod(dim(bvec)[1:3]), replace=TRUE))
ms <- split_reduce(bvec, fac)
ms2 <- split_reduce(bvec, fac, mean)
all.equal(row.names(ms), levels(fac))
all.equal(ms, ms2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.