Skip to contents

[Superseded]

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

Usage

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

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

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.

Value

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

Methods

Implementation of the generic dplyr::transmute() method.

See also

Examples

library(terra)

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

v |>
  transmute(cpro2 = paste0(cpro, "-CyL"))
#>  class       : SpatVector 
#>  geometry    : polygons 
#>  dimensions  : 9, 1  (geometries, attributes)
#>  extent      : 2892687, 3341372, 2017622, 2361600  (xmin, xmax, ymin, ymax)
#>  source      : cyl.gpkg
#>  coord. ref. : ETRS89-extended / LAEA Europe (EPSG:3035) 
#>  names       :  cpro2
#>  type        :  <chr>
#>  values      : 05-CyL
#>                09-CyL
#>                24-CyL