replace_dollar function

Replace with $<-

Replace with $<-

Replace a layer of a SpatRaster, or an attribute variable of a SpatVector

## S4 replacement method for signature 'SpatRaster' x$name <- value ## S4 replacement method for signature 'SpatVector' x$name<-value ## S4 replacement method for signature 'SpatExtent' x$name <- value

Arguments

  • x: SpatRaster, SpatVector or SpatExtent
  • name: character. If x is a SpatRaster: layer name. If x is a SpatVector: variable name. If x is a SpatExtent: "xmin", "xmax". "ymin" or "ymax"
  • value: if x is a SpatRaster, a SpatRaster for which this TRUE: nlyr(value) == length(i); if x is a SpatVector, a vector of new values; if x is a SpatExtent a single number

Returns

Same as x

See Also

[[<-, [<-, $

Examples

f <- system.file("ex/lux.shp", package="terra") v <- vect(f) v$ID_1 <- LETTERS[1:12] v$new <- sample(12) values(v)
  • Maintainer: Robert J. Hijmans
  • License: GPL (>= 3)
  • Last published: 2025-02-26