Learn R Programming

doBy (version 4.6.21)

matrix_op: Matrix operations based on matching dimensions

Description

Matrix operations based on matching dimensions

Usage

matrix_op(m1, m2, op = `+`)

Arguments

m1, m2

matrices with dimnames

op

the operation to be performed

Examples

Run this code
nms1 <- letters[1:4]
mat1 <- matrix(1:8, nrow=4, ncol=4, dimnames=list(nms1, nms1))

nms2 <- letters[2:3]
mat2 <- matrix(11:18, nrow=2, ncol=4, dimnames=list(nms2, nms1))

matrix_op(mat1, mat2)
matrix_op(mat1, mat2, `*`)

Run the code above in your browser using DataLab