Learn R Programming

holodeck (version 0.2.2)

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

Description

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

Usage

set_diag(x, value)

Value

a matrix

Arguments

x

a matrix

value

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

Examples

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

Run the code above in your browser using DataLab