Learn R Programming

scidb (version 1.2-0)

sweep-methods: Methods for Function sweep in Package scidb

Description

Return an array obtained from an input array by sweeping out a summary statistic.

Usage

"sweep"(x, MARGIN, STATS, FUN = "-", eval = FALSE, name)

Arguments

x
a scidb object.
MARGIN
a vector of indices giving the extent(s) of 'x' which correspond to 'STATS'.
STATS
the summary statistic which is to be swept out.
FUN
the function to be used to carry out the sweep. (Default is "-".)
eval
(Optional) If TRUE, execute the query and store the reult array. Otherwise defer evaluation.
name
If x is a multi-attribute array, specify the attribute to work on, default to the first listed array attribute.

Value

scidb object.

Details

STATS must be a vector whose length matches the dimension size of the specified MARGIN. Note that this is a more restrictive condition than the usual R sweep function.

The default value of FUN is "-". FUN must be a quoted binary operator.

Examples

Run this code
## Not run: 
# set.seed(1)
# A <- as.scidb(matrix(rnorm(20),nrow=5))
# # Center the matrix
# B <- sweep(A, MARGIN=2, STATS=apply(A,2,mean))
# # Let's see:
# apply(B,2,mean)[]
# ## End(Not run)

Run the code above in your browser using DataLab