[.sk | R Documentation |
Copies the specified list element or grid point value
## S3 method for class 'sk'
x[i = NULL, j = NULL, drop = FALSE, ...]
x |
a sk object |
i |
column-vectorized index |
j |
index of layer (only for multi-layer x) |
drop |
ignored |
... |
ignored |
Behavior depends on the class of i. For character vectors this extracts the named list entries of x. For numeric, it accesses the vectorized grid data values. For multi-layer objects, a layer can be specified in j.
the default NULL
for i
and j
is treated as numeric, and is shorthand for all
indices. For example if x
has a single-layer x[]
returns all grid data in a vector.
If x
is multi-layer x[,1]
all grid data from the first layer, and x[]
returns all
layers, as a matrix.
a list, vector, or matrix (see description)
# define a sk list and extract two of its elements
g = sk_validate(list(gval=stats::rnorm(4^2), gdim=4, gres=0.5))
g[c('gdim', 'gres')]
# display all the grid data as a vector or a matrix
g[]
matrix(g[], dim(g))
# extract a particular grid point or a subset
g[1]
g[seq(5)]
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.