powered by
An optimized function equivalent to sweep(x, 2, STATS) for a matrix x.
sweep(x, 2, STATS)
x
sweep_cols.matrix(x, STATS, disable_checks = FALSE)
A matrix of the same attributes as x.
a numeric matrix;
a numeric vector whose length equals to the number of columns of x.
if TRUE, do not check that x is a numeric matrix and its number of columns matches the length of STATS; set in production code for a significant speed-up.
TRUE
STATS
x <- matrix(runif(1000), ncol=4) s <- 1:4 stopifnot(all.equal(sweep_cols.matrix(x, s), sweep(x, 2, s)))
Run the code above in your browser using DataLab