Learn R Programming

terra (version 0.8-5)

subset-vector: Subset of a SpatVector

Description

Select a subset of variables or records from a SpatVector.

Usage

# S4 method for SpatVector
subset(x, subset, drop=FALSE, ...)

Arguments

x

SpatVector

subset

logical expression indicating elements or rows to keep: missing values are taken as false

drop

logical. If TRUE, the geometries will be dropped, and a data.frame is returned

...

additional arguments. None implemented

Value

SpatVector or, if drop=TRUE, a data.frame.

Examples

Run this code
# NOT RUN {
f <- system.file("ex/lux.shp", package="terra")
v <- vect(f)
v[2:3,]
v[,2:3]
subset(v, v$NAME_1 == "Diekirch") 
# }

Run the code above in your browser using DataLab