| rename.Spat | R Documentation |
rename() changes the names of individual layers/attributes using
new_name = old_name syntax; rename_with() renames layers/attributes
using a function.
## S3 method for class 'SpatRaster'
rename(.data, ...)
## S3 method for class 'SpatRaster'
rename_with(.data, .fn, .cols = everything(), ...)
## S3 method for class 'SpatVector'
rename(.data, ...)
## S3 method for class 'SpatVector'
rename_with(.data, .fn, .cols = everything(), ...)
.data |
A |
... |
Depending on the function:
|
.fn |
A function used to transform the selected |
.cols |
< |
A Spat* object of the same class than .data. See Methods.
names(Spat*) <- c("a", "b", "c")
Implementation of the generic dplyr::rename() function.
SpatRasterRename layers of a SpatRaster.
SpatVectorThe result is a SpatVector with the renamed attributes on the function
call.
dplyr::rename()
Other single table verbs:
arrange.SpatVector(),
filter.Spat,
mutate.Spat,
select.Spat,
slice.Spat,
summarise.SpatVector()
Other dplyr verbs that operate on columns:
glimpse.Spat,
mutate.Spat,
pull.Spat,
relocate.Spat,
select.Spat
Other dplyr methods:
arrange.SpatVector(),
bind_cols.SpatVector,
bind_rows.SpatVector,
count.SpatVector(),
distinct.SpatVector(),
filter-joins.SpatVector,
filter.Spat,
glimpse.Spat,
group-by.SpatVector,
mutate-joins.SpatVector,
mutate.Spat,
pull.Spat,
relocate.Spat,
rowwise.SpatVector(),
select.Spat,
slice.Spat,
summarise.SpatVector()
library(terra)
f <- system.file("extdata/cyl_tile.tif", package = "tidyterra")
spatrast <- rast(f) %>% mutate(aa = 1, bb = 2, cc = 3)
spatrast
spatrast %>% rename(
this_first = cyl_tile_1,
this_second = cyl_tile_2
)
spatrast %>% rename_with(
toupper,
.cols = starts_with("c")
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.