Description Usage Arguments Details Note Author(s) See Also Examples

Extract or replace the diagonal of a matrix, or construct a diagonal matrix with the same behaviors as `diag`

prior to R-3.0.0.

1 2 |

`x` |
A matrix, vector or 1D array, or missing. |

`...` |
Optional dimensions ( |

`value` |
Either a single value or a vector of length equal to that
of the current diagonal. Should be of a mode which can be coerced
to that of |

Started from R-3.0.0, `diag(x)`

returns a numeric matrix with NA in the
diagonals when x is a character vector. Although this follows what the manual says, this
breaks the metaSEM. The `Diag`

has the same functions as
`diag`

except that `Diag(x)`

works for a character vector of
x by returning a square matrix of character "0" with `x`

as the
diagonals.

See http://r.789695.n4.nabble.com/Behaviors-of-diag-with-character-vector-in-R-3-0-0-td4663735.html for the discussion.

Mike W.-L. Cheung <[email protected]>

1 2 |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.