Skip to content

Methods that Apply to Rows and Columns of Matrices (and to Vectors)

Notifications You must be signed in to change notification settings

nitinl/matrixStats

 
 

Repository files navigation

matrixStats: Methods that Apply to Rows and Columns of a Matrix

UPDATE: Students, please see our Google Summer of Code 2015 project Subsetted and parallel computations in matrixStats for further enhancements of the matrixStats package. Application deadline is March 27, 2015.

The matrixStats package provides highly optimized functions for computing common summaries over rows and columns of matrices, e.g. rowQuantiles(). There are also functions that operate on vectors, e.g. logSumExp(). Their implementations strive to minimize both memory usage and processing time. They are often remarkably faster compared to good old apply() solutions. The calculations are mostly implemented in C, which allow us to optimize beyond what is possible to do in plain R. The package installs out-of-the-box on all common operating systems, including Linux, OS X and Windows.

Example

It is many times faster to calculate medians column by column using

> library("matrixStats")
> X <- matrix(rnorm(20 * 500), nrow = 20, ncol = 500)
> mu <- colMedians(X)

compared with

> mu <- apply(X, MARGIN=2, FUN=medians)

Benchmarks

For formal benchmarking of matrixStats functions relative to alternatives, see the Benchmark reports.

Installation

R package matrixStats is available on CRAN and can be installed in R as:

install.packages('matrixStats')

Software quality

Resource: CRAN Travis CI Appveyor
Platforms: Multiple Linux Windows
R CMD check status Build status
Test coverage Coverage Status

About

Methods that Apply to Rows and Columns of Matrices (and to Vectors)

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • R 52.0%
  • C 39.1%
  • Makefile 6.3%
  • Objective-C 2.6%