symMatrix: Symmetric Matrix

Description Usage Arguments Value Author(s) See Also Examples

View source: R/utils.R

Description

Create a Symmetric Matrix.

Usage

1
2
   symMatrix( data = NA, nrow = NULL, byrow = FALSE,
   upper = FALSE )

Arguments

data

an optional data vector.

nrow

the desired number of rows and columns.

byrow

logical. If 'FALSE' (the default) the matrix is filled by columns, otherwise the matrix is filled by rows.

upper

logical. If 'FALSE' (the default) the lower triangular part of the matrix (including the diagonal) is filled, otherwise the upper triangular part of the matrix is filled.

Value

a symmetric matrix.

Author(s)

Arne Henningsen

See Also

matrix, lower.tri.

Examples

1
2
3
4
5
6
   # fill the lower triangular part by columns
   symMatrix( 1:10, 4 )
   # fill the upper triangular part by columns
   symMatrix( 1:10, 4, upper = TRUE )
   # fill the lower triangular part by rows
   symMatrix( 1:10, 4, byrow = FALSE )

miscTools documentation built on Dec. 9, 2019, 3 a.m.