SpatVector objectsMethods for the dplyr::rows_insert() family on SpatVector objects.
# S3 method for SpatVector
rows_insert(
x,
y,
by = NULL,
...,
conflict = c("error", "ignore"),
copy = FALSE,
in_place = FALSE
)# S3 method for SpatVector
rows_append(x, y, ..., copy = FALSE, in_place = FALSE)
# S3 method for SpatVector
rows_update(
x,
y,
by = NULL,
...,
unmatched = c("error", "ignore"),
copy = FALSE,
in_place = FALSE
)
# S3 method for SpatVector
rows_patch(
x,
y,
by = NULL,
...,
unmatched = c("error", "ignore"),
copy = FALSE,
in_place = FALSE
)
# S3 method for SpatVector
rows_upsert(x, y, by = NULL, ..., copy = FALSE, in_place = FALSE)
# S3 method for SpatVector
rows_delete(
x,
y,
by = NULL,
...,
unmatched = c("error", "ignore"),
copy = FALSE,
in_place = FALSE
)
A SpatVector.
A SpatVector.
A data frame, sf object or SpatVector.
An unnamed character vector giving the key columns. The key columns
must exist in both x and y. Keys typically uniquely identify each row,
but this is only enforced for the key values of y when rows_update(),
rows_patch(), or rows_upsert() are used.
By default, we use the first column in y, since the first column is
a reasonable place to put an identifier variable.
Other parameters passed onto methods.
For rows_insert(), how should keys in y that conflict
with keys in x be handled? A conflict arises if there is a key in y
that already exists in x.
One of:
"error", the default, will error if there are any keys in y that
conflict with keys in x.
"ignore" will ignore rows in y with keys that conflict with keys in
x.
If x and y are not from the same data source,
and copy is TRUE, then y will be copied into the
same src as x. This allows you to join tables across srcs, but
it is a potentially expensive operation so you must opt into it.
Should x be modified in place? This argument is only
relevant for mutable backends (e.g. databases, data.tables).
When TRUE, a modified version of x is returned invisibly;
when FALSE, a new object representing the resulting changes is returned.
For rows_update(), rows_patch(), and rows_delete(),
how should keys in y that are unmatched by the keys in x be handled?
One of:
"error", the default, will error if there are any keys in y that
are unmatched by the keys in x.
"ignore" will ignore rows in y with keys that are unmatched by the
keys in x.
Implementation of the generic dplyr::rows_insert() method family for
SpatVector objects.
Row operations update attributes while preserving the geometry column. When inserting data frame rows without geometry, the output contains empty geometries for the new rows.
Other dplyr verbs that operate on rows:
arrange.SpatVector(),
distinct.SpatVector(),
filter.Spat,
slice.Spat
Other dplyr verbs that operate on pairs of SpatVector and data frame objects:
bind_cols.SpatVector,
bind_rows.SpatVector,
cross_join.SpatVector(),
filter-joins.SpatVector,
mutate-joins.SpatVector,
nest_join.SpatVector()
v <- terra::vect(system.file("extdata/cyl.gpkg", package = "tidyterra"))
rows_update(
v,
tibble::tibble(cpro = "05", name = "New name"),
by = "cpro"
)
rows_insert(
v,
tibble::tibble(cpro = "99", name = "New province"),
by = "cpro"
)
Run the code above in your browser using DataLab