powered by
SpatVector
uncount() duplicates rows according to a weighting variable.
uncount()
# S3 method for SpatVector uncount(data, weights, ..., .remove = TRUE, .id = NULL)
A SpatVector object.
A SpatVector.
A vector of weights. Evaluated in the context of data; supports quasiquotation.
data
Additional arguments passed on to methods.
If TRUE, and weights is the name of a column in data, then this column is removed.
TRUE
weights
Supply a string to create a new variable which gives a unique identifier for each created row.
Implementation of the generic tidyr::uncount() method for SpatVector objects.
tidyr::uncount()
Each duplicated row keeps the input geometry.
tidyr::uncount().
library(tidyr) v <- terra::vect(system.file("extdata/cyl.gpkg", package = "tidyterra")) v$copies <- rep_len(1:2, nrow(v)) uncount(v, copies)
Run the code above in your browser using DataLab