Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

sub-XArray-ANY-ANY-method

Indexing to extract subsets of a codeRasterArray or SpatialArray object


Description

Single bracket '[' refers to indices and names within the RasterArray . Use double brackets to extract layers based on their names (in the stack).

Usage

## S4 method for signature 'XArray,ANY,ANY'
x[i, j, ..., drop = TRUE]

Arguments

x

RasterArray or SpatialArray object.

i

subscript of the first dimension(rows) or vector-like subsetting.

j

subscript of the second dimension (columns).

...

subscript of additional dimensions.

drop

logical in case the result of subsetting is a single element, should the RasterArray or SpatialArray wrapper be dropped and the element be reduced to a single RasterLayer or Spatial*?

Value

A RasterLayer, RasterArray, Spatial* or SpatialArray class object.

Examples

data(dems)
# numeric subsetting
firstThree <- dems[1:3]
# character subsetting
second <- dems["10"]
# logical subsetting
subscript <- rep(FALSE, length(dems))
subscript[2] <- TRUE
second2 <- dems[subscript]
data(coasts)
present<- coasts["0", ]
allMargin <- coasts[, "margin"]

chronosphere

Earth System History Variables

v0.4.1
CC BY 4.0
Authors
Adam T. Kocsis, Nussaibah B. Raja
Initial release
2021-04-16

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.