Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

diag-character-method

Create a diagonal matrix from a character vector


Description

Create a diagonal matrix from a character vector

Usage

## S4 method for signature 'character'
diag(x = 1, nrow, ncol)

Arguments

x

Character vector used to create the matrix

nrow

Numeric. Number of rows for the resulting matrix.

ncol

Numeric. Number of columns for the resulting matrix.

Details

We create a new method for diag with character input. The default behavior for missing nrow and/or ncol arguments is the same as for the diag function in the base package. Off-diagonal entries are filled with "0".

Value

A matrix

Examples

diag(letters[1:3])

dynr

Dynamic Models with Regime-Switching

v0.1.16-2
GPL-3
Authors
Lu Ou [aut], Michael D. Hunter [aut, cre] (<https://orcid.org/0000-0002-3651-6709>), Sy-Miin Chow [aut] (<https://orcid.org/0000-0003-1938-027X>), Linying Ji [aut], Meng Chen [aut], Hui-Ju Hung [aut], Jungmin Lee [aut], Yanling Li [aut], Jonathan Park [aut], Massachusetts Institute of Technology [cph], S. G. Johnson [cph], Benoit Scherrer [cph], Dieter Kraft [cph]
Initial release
2021-03-12

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.