colsums: Column and row-wise sums of a matrix

Description Usage Arguments Value Author(s) See Also Examples

View source: R/sum.R

Description

Column and row-wise sums of a matrix.

Usage

1
2
3
colsums(x,indices = NULL, parallel = FALSE)

rowsums(x,indices = NULL, parallel = FALSE)

Arguments

x

A numerical matrix with data.

indices

An integer vector with the indices to sum the columns/rows.

parallel

Do you want to do it in parallel in C++? TRUE or FALSE. Doens't work with argument "indices".

Value

A vector with sums.

Author(s)

Manos Papadakis

R implementation and documentation: Manos Papadakis <papadakm95@gmail.com>.

See Also

colMedians, colmeans, colVars

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
x <- matrix(rpois(500 * 100, 10),ncol = 100)
x1 <- colsums(x)
x2 <- colSums(x)
all.equal(x1,x2)

x1 <- rowsums(x)
x2 <- rowSums(x)
all.equal(x1,x2)

x<-x1<-x2<-NULL

Example output

Loading required package: Rcpp
Loading required package: RcppZiggurat
[1] TRUE
[1] TRUE

Rfast documentation built on May 18, 2021, 1:07 a.m.