Learn R Programming

MoBPS (version 1.6.64)

add.diag: Add something to the diagonal

Description

Function to add numeric to the diagonal of a matrix

Usage

add.diag(M, d)

Arguments

M

Matrix

d

Vector to add to the diagonal of the matrix

Value

Matrix with increased diagonal elements

Matrix with modified diagonal entries

Examples

Run this code
# NOT RUN {
A <- matrix(c(1,2,3,4), ncol=2)
B <- add.diag(A, 5)
# }

Run the code above in your browser using DataLab