merge-methods: Merge Objects Stored in a List

mergeR Documentation

Merge Objects Stored in a List

Description

Complementing existing merge methods, e.g. terra::merge() for Spat* objects, which typically work with one or two inputs only, this function accepts a list of objects that are to be merged together.

Usage

## S4 method for signature 'list,missing'
merge(x, by = 1L, all = TRUE, ...)

Arguments

x

A list of objects of the same type (e.g. Spat* or data.frame).

by, all

See merge.data.frame(). Ignored if data stored in 'x' is not of class data.frame.

...

Additional arguments passed to the underlying merge method (e.g. arguments compatible with terra::merge() and terra::writeRaster() for Spat* input). Ignored if data stored in 'x' is of class data.frame.

Value

A merged object (e.g. a new Spat* object with a larger spatial extent).

Author(s)

Florian Detsch

See Also

do.call(), Reduce().

Examples

## `SpatRaster` input
dms = list.files(system.file("extdata", package = "Orcs")
                 , pattern = "ASTGTM2.*dem.tif$", full.names = TRUE)
dms = lapply(dms, terra::rast)

dem = merge(dms[3:4])
terra::plot(dem)

## data.frame input
mrg = merge(list(iris, iris, iris)
            , by = c("Species", "Sepal.Length", "Petal.Width"))
head(mrg)


Orcs documentation built on Jan. 6, 2023, 5:14 p.m.