Learn R Programming

countdata (version 1.3)

normalize: Global normalization of count data

Description

Normalize a numerical matrix by scaling each column so that the scaled column sums are equal.

Usage

normalize(d)

Value

A matrix of the same size as d is returned. The column sums of this matrix are equal.

Arguments

d

A numerical matrix.

Author

Thang V. Pham

Details

The average of column sums is computed. A scaling factor is calculated for each colunm so that the scaled column sum is equal to the computed average value.

References

Pham TV (2021). countdata: The Beta-Binomial Test for Count Data. R package version 1.1. https://CRAN.R-project.org/package=countdata

Examples

Run this code
d <- rbind(c(2.5, 11.2, 7.2),
           c(9.1, 2.2, 7.1))

colSums(d)
# 11.6 13.4 14.3

colSums(normalize(d))
# 13.1 13.1 13.1

Run the code above in your browser using DataLab