Description Arguments Details Usage Examples
Generic methods to extract and replace elements of greta arrays, or to combine greta arrays.
x |
a greta array |
i, j |
indices specifying elements to extract or replace |
n |
a single integer, as in |
nrow, ncol |
optional dimensions for the resulting greta array when x is not a matrix. |
value |
for |
... |
either further indices specifying elements to extract or replace
( |
drop, recursive |
generic arguments that are ignored for greta arrays |
diag()
can be used to extract or replace the diagonal part of
a square and two-dimensional greta array, but it cannot be used to create a
matrix-like greta array from a scalar or vector-like greta array. A static
diagonal matrix can always be created with e.g. diag(3)
, and then
converted into a greta array.
Also note that since R 4.0.0, head
and tail
methods for arrays changed
to print a vector rather than maintain the array structure. The greta
package supports both methods, and will do so based on which version of R
you are using.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | # extract
x[i]
x[i, j, ..., drop = FALSE]
head(x, n = 6L, ...)
tail(x, n = 6L, ...)
diag(x, nrow, ncol)
# replace
x[i] <- value
x[i, j, ...] <- value
diag(x) <- value
# combine
cbind(...)
rbind(...)
abind(...)
c(..., recursive = FALSE)
rep(x, times, ..., recursive = FALSE)
# get and set dimensions
length(x)
dim(x)
dim(x) <- value
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.