{{ message }}

# HenrikBengtsson / matrixStats

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

## Latest commit

`…gical' input. Related to #159`
7e34c76

## Files

Failed to load latest commit information.
Type
Name
Commit time
Sep 24, 2020
Mar 29, 2017
Nov 26, 2020
Jul 21, 2019
Sep 24, 2020
Sep 24, 2020
Mar 10, 2020
Sep 24, 2020
Nov 26, 2020
Sep 10, 2019
Apr 2, 2017
Sep 24, 2020

# matrixStats: Functions that Apply to Rows and Columns of Matrices (and to Vectors)

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, macOS and Windows.

## Example

With a matrix

`> x <- matrix(rnorm(20 * 500), nrow = 20, ncol = 500)`

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

`> mu <- matrixStats::colMedians(x)`

than using

`> mu <- apply(x, MARGIN = 2, FUN = median)`

Moreover, if performing calculations on a subset of rows and/or columns, using

`> mu <- colMedians(x, rows = 33:158, cols = 1001:3000)`

is much faster and more memory efficient than

`> mu <- apply(x[33:158, 1001:3000], MARGIN = 2, FUN = median)`

## 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")`

### Pre-release version

To install the pre-release version that is available in Git branch `develop` on GitHub, use:

`remotes::install_github("HenrikBengtsson/matrixStats", ref="develop")`

This will install the package from source. Because of this and because this package also compiles native code, Windows users need to have Rtools installed and macOS users need to have Xcode installed.

## Contributions

This Git repository uses the Git Flow branching model (the `git flow` extension is useful for this). The `develop` branch contains the latest contributions and other code that will appear in the next release, and the `master` branch contains the code of the latest release, which is exactly what is currently on CRAN.

Contributing to this package is easy. Just send a pull request. When you send your PR, make sure `develop` is the destination branch on the matrixStats repository. Your PR should pass `R CMD check --as-cran`, which will also be checked by Travis CI and AppVeyor CI when the PR is submitted.

We abide to the Code of Conduct of Contributor Covenant.

## Software status

Resource CRAN GitHub Actions Travis CI AppVeyor CI
Platforms: Multiple Multiple Linux & macOS Windows
R CMD check
Test coverage

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

28 tags

## Packages 0

No packages published

## Languages

You can’t perform that action at this time.