
Last chance! 50% off unlimited learning
Sale ends in
These functions extend the respective base functions by (optionally) preserving the shape of the array (i.e. the summed dimensions have length 1).
# S4 method for matrix
colSums(x, na.rm = FALSE, dims = 1L, drop = TRUE)colSums.AsIs(x, ...)
# S4 method for array
colSums(x, na.rm = FALSE, dims = 1L, drop = TRUE)
# S4 method for matrix
colMeans(x, na.rm = FALSE, dims = 1L, drop = TRUE)
colMeans.AsIs(x, ...)
# S4 method for array
colMeans(x, na.rm = FALSE, dims = 1L, drop = TRUE)
# S4 method for matrix
rowSums(x, na.rm = FALSE, dims = 1L, drop = TRUE)
rowSums.AsIs(x, ...)
# S4 method for array
rowSums(x, na.rm = FALSE, dims = 1L, drop = TRUE)
# S4 method for matrix
rowMeans(x, na.rm = FALSE, dims = 1L, drop = TRUE)
rowMeans.AsIs(x, ...)
# S4 method for array
rowMeans(x, na.rm = FALSE, dims = 1L, drop = TRUE)
an array of two or more dimensions, containing numeric, complex, integer or logical values, or a numeric data frame.
logical indicating treatment of missing values
integer: Which dimensions are regarded as ‘rows’ or ‘columns’ to sum
over. For row*
, the sum or mean is over dimensions dims + 1, …
; for col*
it is over dimensions 1 : dims
.
If FALSE
, the number of dimensions is retained: the length of the dimensions
that are summed or averaged is set to 1. TRUE
yield the same behaviour as
colSums
the signature = "AsIs"
methods hand on all parameters
like colSums
if drop = TRUE
, otherwise an array where the
summed dimensions have length 1.
# NOT RUN {
a <- array (1 : 24, 4 : 2)
a
rowSums (a)
rowSums (a, drop = FALSE)
colSums (a)
colSums (a, drop = FALSE)
colSums (a, dim = 2)
colSums (a, dim = 2, drop = FALSE)
# }
Run the code above in your browser using DataLab