MAT_divide_rowwise: Divide a matrix or df row-wise by a vector

View source: R/matrices.R

MAT_divide_rowwiseR Documentation

Divide a matrix or df row-wise by a vector

Description

The default use of / divides column-wise, but sometimes row-wise is needed. This function restores the dimnames.

Usage

MAT_divide_rowwise(data, divisor)

Arguments

data

(mat or df) Data to divide.

divisor

(num/int vectr) Divisor to use.

Value

Returns a data.frame/matrix with the orignal dimnames.

Examples

m = matrix(1:10, ncol=2)
m
m/c(1, 2) #divide column-wise
MAT_divide_rowwise(m, c(1, 2)) #row-wise
#works on data.frames too
MAT_divide_rowwise(iris[-5], c(1, 999, 1, 999)) %>% head

Deleetdk/kirkegaard documentation built on April 22, 2024, 5:22 p.m.