View source: R/divide_rows_cols.R
divide_rows | R Documentation |
Convenience functions for dividing rows and columns of a matrix by a given vector
divide_rows(mat, vec)
divide_cols(mat, vec)
mat |
A matrix. Can be a sparseMatrix from Matrix |
vec |
divide_rows
(divide_cols
) divide the i-th row
(i-th column) of mat
by the i-th entry of vec
.
Formally, divide_rows(mat, vec)
is equivalent to
sweep(mat, 1, vec "/"), but is usually more efficient, and
plays nicer with magrittr pipe %>%
.
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.