divide_rows: Convenience functions for dividing rows and columns of a...

View source: R/divide_rows_cols.R

divide_rowsR Documentation

Convenience functions for dividing rows and columns of a matrix by a given vector

Description

Convenience functions for dividing rows and columns of a matrix by a given vector

Usage

divide_rows(mat, vec)

divide_cols(mat, vec)

Arguments

mat

A matrix. Can be a sparseMatrix from Matrix

vec

Details

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 %>%.

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)



c7rishi/hidgenclassifier documentation built on June 14, 2024, 11:10 a.m.