rowQuantiles | R Documentation |
Estimates quantiles for each row (column) in a matrix.
rowQuantiles(x, rows = NULL, cols = NULL, probs = seq(from = 0, to = 1,
by = 0.25), na.rm = FALSE, type = 7L, digits = 7L, ...,
useNames = TRUE, drop = TRUE)
colQuantiles(x, rows = NULL, cols = NULL, probs = seq(from = 0, to = 1,
by = 0.25), na.rm = FALSE, type = 7L, digits = 7L, ...,
useNames = TRUE, drop = TRUE)
x |
An |
rows |
A |
cols |
A |
probs |
A |
na.rm |
If |
type |
An |
digits |
An |
... |
Additional arguments passed to |
useNames |
If |
drop |
If TRUE, singleton dimensions in the result are dropped, otherwise not. |
Returns a NxJ (KxJ) matrix
, where N (K) is the
number of rows (columns) for which the J quantiles are calculated.
The return type is either integer or numeric depending on type
.
Henrik Bengtsson
quantile
.
set.seed(1)
x <- matrix(rnorm(50 * 40), nrow = 50, ncol = 40)
str(x)
probs <- c(0.25, 0.5, 0.75)
# Row quantiles
q <- rowQuantiles(x, probs = probs)
print(q)
q_0 <- apply(x, MARGIN = 1, FUN = quantile, probs = probs)
stopifnot(all.equal(q_0, t(q)))
# Column IQRs
q <- colQuantiles(x, probs = probs)
print(q)
q_0 <- apply(x, MARGIN = 2, FUN = quantile, probs = probs)
stopifnot(all.equal(q_0, t(q)))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.