Learn R Programming

salad (version 1.2)

diag: Matrix diagonals

Description

Methods extending to dual objects the corresponding methods for numeric objects.

Usage

diag.dual(x, nrow, ncol, names = TRUE)

# S4 method for dual diag(x = 1, nrow, ncol, names = TRUE)

# S4 method for dual,dual diag(x) <- value

# S4 method for dual,numericOrArray diag(x) <- value

Value

A dual object, similarly to `base::diag`

Arguments

x

a dual object

nrow, ncol

(optional) dimensions of result

names

if 'TRUE', pass names along

value

replacement value

Examples

Run this code
x <- dual( c(1,2) )
diag(x)
d(diag(x), "x1")
y <- matrix(x, 2, 2)
diag(y) <- 2*diag(y)
y
d(y)
diag(y)

Run the code above in your browser using DataLab