-
Notifications
You must be signed in to change notification settings - Fork 0
/
colDivide.Rd
25 lines (24 loc) · 1.1 KB
/
colDivide.Rd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/CodeAndRoll2.R
\name{colDivide}
\alias{colDivide}
\title{Row-wise division of a matrix by a column vector}
\usage{
colDivide(mat, vec = colSums(mat))
}
\arguments{
\item{mat}{A numeric matrix where each row represents a distribution to be divided.}
\item{vec}{A numeric vector whose elements are the divisors for each column of the matrix.
The length of the vector must match the number of columns in the matrix. If not supplied,
the default is to use the column sums of the matrix as divisors.}
}
\value{
A matrix with the same dimensions as the input where each element in the original matrix
has been divided by the corresponding element in the vector.
}
\description{
Each element of the matrix is divided by the corresponding element of the vector
that matches the column of the matrix element. This is typically used to normalize data,
for example, to scale values in each row by certain factors like totals or means. Soruce
\url{https://stackoverflow.com/questions/20596433/how-to-divide-each-row-of-a-matrix-by-elements-of-a-vector-in-r}.
}