Creates an upper triangular square matrix from a vector.

triang( v, n )

Arguments

v

vector

n

desired dimension of the returned square matrix

Note

If the vector has less elements than the upper triangular matrix, the last elements are set to zero.

See also

Author

Arne Henningsen

Examples

   v <- c( 1:5 )
   triang( v, 3 )
#>      [,1] [,2] [,3]
#> [1,]    1    2    3
#> [2,]    0    4    5
#> [3,]    0    0    0