-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdivide_rows.Rd
More file actions
41 lines (36 loc) · 910 Bytes
/
divide_rows.Rd
File metadata and controls
41 lines (36 loc) · 910 Bytes
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/divide_rows_cols.R
\name{divide_rows}
\alias{divide_rows}
\alias{divide_cols}
\title{Convenience functions for dividing rows and columns of a matrix
by a given vector}
\usage{
divide_rows(mat, vec)
divide_cols(mat, vec)
}
\arguments{
\item{mat}{A matrix. Can be a sparseMatrix from {Matrix}}
\item{vec}{}
}
\description{
Convenience functions for dividing rows and columns of a matrix
by a given vector
}
\details{
\code{divide_rows} (\code{divide_cols}) divide the i-th row
(i-th column) of \code{mat} by the i-th entry of \code{vec}.
Formally, \code{divide_rows(mat, vec)} is equivalent to
sweep(mat, 1, vec "/"), but is usually more efficient, and
plays nicer with {magrittr} pipe \code{\%>\%}.
}
\examples{
mat <- rbind(
c(2, 3, 4),
c(3, 4, 5),
c(8, 9, 10)
)
vec <- c(1, 2, 3)
divide_rows(mat, vec)
divide_cols(mat, vec)
}