Methods for the dplyr::rows_insert() family on SpatVector objects.
Usage
# S3 method for class 'SpatVector'
rows_insert(
x,
y,
by = NULL,
...,
conflict = c("error", "ignore"),
copy = FALSE,
in_place = FALSE
)
# S3 method for class 'SpatVector'
rows_append(x, y, ..., copy = FALSE, in_place = FALSE)
# S3 method for class 'SpatVector'
rows_update(
x,
y,
by = NULL,
...,
unmatched = c("error", "ignore"),
copy = FALSE,
in_place = FALSE
)
# S3 method for class 'SpatVector'
rows_patch(
x,
y,
by = NULL,
...,
unmatched = c("error", "ignore"),
copy = FALSE,
in_place = FALSE
)
# S3 method for class 'SpatVector'
rows_upsert(x, y, by = NULL, ..., copy = FALSE, in_place = FALSE)
# S3 method for class 'SpatVector'
rows_delete(
x,
y,
by = NULL,
...,
unmatched = c("error", "ignore"),
copy = FALSE,
in_place = FALSE
)Arguments
- x
A
SpatVector.- y
A data frame,
sfobject orSpatVector.- by
An unnamed character vector giving the key columns. The key columns must exist in both
xandy. Keys typically uniquely identify each row, but this is only enforced for the key values ofywhenrows_update(),rows_patch(), orrows_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.
- conflict
For
rows_insert(), how should keys inythat conflict with keys inxbe handled? A conflict arises if there is a key inythat already exists inx.One of:
"error", the default, will error if there are any keys inythat conflict with keys inx."ignore"will ignore rows inywith keys that conflict with keys inx.
- copy
If
xandyare not from the same data source, andcopyisTRUE, thenywill be copied into the same src asx. This allows you to join tables across srcs, but it is a potentially expensive operation so you must opt into it.- in_place
Should
xbe modified in place? This argument is only relevant for mutable backends (e.g. databases, data.tables).When
TRUE, a modified version ofxis returned invisibly; whenFALSE, a new object representing the resulting changes is returned.- unmatched
For
rows_update(),rows_patch(), androws_delete(), how should keys inythat are unmatched by the keys inxbe handled?One of:
"error", the default, will error if there are any keys inythat are unmatched by the keys inx."ignore"will ignore rows inywith keys that are unmatched by the keys inx.
Methods
Implementation of the generic dplyr::rows_insert() family for
SpatVector objects.
See also
Other dplyr verbs that operate on rows:
arrange.SpatVector(),
distinct.SpatVector(),
filter.Spat,
slice.Spat
Other dplyr verbs that operate on pairs Spat*/data.frame:
bind_cols.SpatVector,
bind_rows.SpatVector,
cross_join.SpatVector(),
filter-joins.SpatVector,
mutate-joins.SpatVector,
nest_join.SpatVector()
Other dplyr methods:
arrange.SpatVector(),
bind_cols.SpatVector,
bind_rows.SpatVector,
count.SpatVector(),
cross_join.SpatVector(),
distinct.SpatVector(),
filter-joins.SpatVector,
filter.Spat,
glimpse.Spat,
group_by.SpatVector(),
mutate-joins.SpatVector,
mutate.Spat,
nest_join.SpatVector(),
pull.Spat,
reframe.SpatVector(),
relocate.Spat,
rename.Spat,
rowwise.SpatVector(),
select.Spat,
slice.Spat,
summarise.SpatVector()
Examples
v <- terra::vect(system.file("extdata/cyl.gpkg", package = "tidyterra"))
rows_update(
v,
tibble::tibble(cpro = "05", name = "New name"),
by = "cpro"
)
#> class : SpatVector
#> geometry : polygons
#> dimensions : 9, 3 (geometries, attributes)
#> extent : 2892687, 3341372, 2017622, 2361600 (xmin, xmax, ymin, ymax)
#> coord. ref. : ETRS89-extended / LAEA Europe (EPSG:3035)
#> names : iso2 cpro name
#> type : <chr> <chr> <chr>
#> values : ES-AV 05 New name
#> ES-BU 09 Burgos
#> ES-LE 24 Leon
#> ...
rows_insert(
v,
tibble::tibble(cpro = "99", name = "New province"),
by = "cpro"
)
#> class : SpatVector
#> geometry : polygons
#> dimensions : 10, 3 (geometries, attributes)
#> extent : 2892687, 3341372, 2017622, 2361600 (xmin, xmax, ymin, ymax)
#> coord. ref. : ETRS89-extended / LAEA Europe (EPSG:3035)
#> names : iso2 cpro name
#> type : <chr> <chr> <chr>
#> values : ES-AV 05 Avila
#> ES-BU 09 Burgos
#> ES-LE 24 Leon
#> ...
