Learn R Programming

tidyterra (version 1.3.0)

transmute.Spat: Create, modify and delete cell values/layers/attributes of Spat* objects

Description

[Superseded]

transmute() creates a new object containing only the specified computations. It is superseded because you can perform the same job with mutate(.keep = "none").

Usage

# S3 method for SpatRaster
transmute(.data, ...)

# S3 method for SpatVector transmute(.data, ...)

Value

A Spat* object of the same class as .data. See Methods.

Arguments

.data

A SpatRaster created with terra::rast() or a SpatVector created with terra::vect().

...

<data-masking> Name-value pairs. The name gives the name of the column in the output.

The value can be:

  • A vector of length 1, which will be recycled to the correct length.

  • A vector the same length as the current group (or the whole data frame if ungrouped).

  • NULL, to remove the column.

  • A data frame or tibble, to create multiple columns in the output.

Methods

Implementation of the generic dplyr::transmute() method for Spat* objects.

See Also

mutate.Spat, dplyr::transmute() methods.

Examples

Run this code
library(terra)

# SpatVector method
f <- system.file("extdata/cyl.gpkg", package = "tidyterra")
v <- vect(f)

v |>
  transmute(cpro2 = paste0(cpro, "-CyL"))

Run the code above in your browser using DataLab