special.matrix: Generating Special Matrices

special.matrixR Documentation

Generating Special Matrices

Description

Creates an Identity Matrix I and a Matrix of Ones J.

  • I(): Creates an identity matrix where the number of columns is n. This is a diagonal matrix with all equal to one (1). An identity matrix is usually written as I. Names of rows and columns (dimnames) are included.

  • J(): Creates a matrix of ones with any number of rows and columns. Names of rows and columns (dimnames) are included.

Usage

I(n)

J(n, m = n)

Arguments

n

Number of rows in I or J.

m

Number of columns in J. Default: Same as number of rows.

See Also

Other matrix: tr(), vec()

Examples

# To create an identity matrix of order 12
I(2)
# To make a matrix of 6 rows and 10 columns of all ones
J(6, 10)
# To make a matrix of unity, dimensions 6 x 6.
J(6)

matrixNormal documentation built on Sept. 16, 2022, 5:07 p.m.