fame (version 1.03)

rowMeans: Form Row Sums and Means


Form row sums and means for numeric arrays.


rowSums (x, ...)
rowMeans(x, ...)
## S3 method for class 'default':
rowSums(x, na.rm = FALSE, dims = 1, \dots)
## S3 method for class 'default':
rowMeans(x, na.rm = FALSE, dims = 1, \dots)
## S3 method for class 'tis':
rowSums(x, \dots)
## S3 method for class 'tis':
rowMeans(x, \dots)


an array of two or more dimensions, containing numeric, complex, integer or logical values, or a numeric data frame, or a tis time indexed series
arguments passed along to rowSums.default or rowMeans.default, which are actually the versions of rowSums and rowMeans from the base package. The ...argument is ignored in rowSums.d
logical. Should missing values (including NaN) be omitted from the calculations?
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


  • A numeric or complex array of suitable size, or a vector if the result is one-dimensional. The dimnames (or names for a vector result) are taken from the original array.

    If there are no values in a range to be summed over (after removing missing values with na.rm = TRUE), that component of the output is set to 0 (rowSums) or NA (rowMeans), consistent with sum and mean.

    The tis-specific methods also return a tis.


These functions are equivalent to use of apply with FUN = mean or FUN = sum with appropriate margins, but are a lot faster. As they are written for speed, they blur over some of the subtleties of NaN and NA. If na.rm = FALSE and either NaN or NA appears in a sum, the result will be one of NaN or NA, but which might be platform-dependent.

See Also

apply, rowsum, and colSums for more details and examples.


Run this code
mat <- tis(matrix(1:36, ncol = 3), start = latestJanuary())
cbind(mat, rowSums(mat), rowMeans(mat))

Run the code above in your browser using DataCamp Workspace