Define function to change the diagonal of array
Usage
diag3Darray(x) <- valueArguments
- x
- 3D arraywhose diagonal must be c hanged
- value
- vectordefining the new values of diagonal.
Details
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.
Examples
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
#> 
#  , , 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
