# NOT RUN {
s <- rast(system.file("ex/logo.tif", package="terra"))
subset(s, 2:3)
subset(s, c(3,2,3,1))
#equivalent to
s[[ c(3,2,3,1) ]]
s[[c("red", "green")]]
s$red
# expresion based (partial) matching of names with single brackets
s["re"]
s["^re"]
# not with double brackets
# s[["re"]]
# }
Run the code above in your browser using DataLab