diag3Darray<- | R Documentation |
Define function to change the diagonal of array
diag3Darray(x) <- value
x |
|
value |
|
The diagonal of a 3D array has been defined as those elements in positions c(int,int,int), i.e., the three digits are the same.
array
with all elements zero except the diagonal, with dimensions c(dim,dim,dim)
x <- array(1, dim = c(3,3,3))
diag3Darray(x) <- c(2,2,2)
x
# , , 1
#
# [,1] [,2] [,3]
# [1,] 2 1 1
# [2,] 1 1 1
# [3,] 1 1 1
#
# , , 2
#
# [,1] [,2] [,3]
# [1,] 1 1 1
# [2,] 1 2 1
# [3,] 1 1 1
#
# , , 3
#
# [,1] [,2] [,3]
# [1,] 1 1 1
# [2,] 1 1 1
# [3,] 1 1 2
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.