Learn R Programming

rosario (version 0.1.1)

rescale_matrix: Row-wise rescaling of a matrix to relative frequencies

Description

Divides each row by its row sum so that every row sums to 1 (leaving dimnames intact).

Usage

rescale_matrix(m)

Value

A numeric matrix of the same dimension with each row summing to 1. Rows with a zero sum are left unchanged (resulting in NaN if present).

Arguments

m

Numeric matrix; rows are biological identities, columns are time bins (i.e., time resources).

Examples

Run this code
ex1_rescale <- rescale_matrix(ex1)
rowSums(ex1_rescale)

Run the code above in your browser using DataLab