Description Usage Arguments Details Value Author(s) See Also Examples
Get and set the upper and lower triangular matrix in vector form.
1 2 3 4 5 6 7 | get.lower.tri(x, diag = FALSE)
get.lower.tri(x, diag = FALSE) <- value
get.upper.tri(x, diag = FALSE)
get.upper.tri(x, diag = FALSE) <- value
|
x |
A |
diag |
logical. Should the diagonal be included? |
value |
A vector of the same data type a |
The returned length is dependent on diag
. If
diag == TRUE
, then the length is ncol(x)*(ncol(x)-1)/2
. If
FALSE
, then the length is ncol(x)*(ncol(x)+1)/2
.
get.lower.tri
returns a numeric vector of the entries in the
below the diagonal of x
. The length is dependent on argument
diag
.
get.upper.tri
returns a numeric vector of the entries in the
below the diagonal of x
. The length is dependent on argument
diag
.
Anders Ellern Bilgrau <anders.ellern.bilgrau (at) gmail.com>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | print(x <- matrix(1:25, ncol = 5))
get.lower.tri(x)
get.lower.tri(x, diag = TRUE)
print(y <- matrix(1:9, ncol = 3))
get.upper.tri(y)
get.upper.tri(y, diag = TRUE)
get.upper.tri(y) <- get.lower.tri(y) # Fill the upper tri with the lower
print(y)
get.upper.tri(y)
print(x)
get.lower.tri(x, diag = TRUE) <- get.upper.tri(x, diag = TRUE)
print(x)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.