set_diag: Pipe friendly wrapper to 'diag(x) <- value'

View source: R/utils.R

set_diagR Documentation

Pipe friendly wrapper to 'diag(x) <- value'

Description

Pipe friendly wrapper to 'diag(x) <- value'

Usage

set_diag(x, value)

Arguments

x

a matrix

value

either a single value or a vector of length equal to the diagonal of 'x'.

Value

a matrix

Examples

library(dplyr)
matrix(0,3,3) %>%
set_diag(1)

holodeck documentation built on Aug. 26, 2023, 1:07 a.m.