# NOT RUN {
x <- rast(xmax=-150, ymin=60, ncols=30, nrows=30)
y <- rast(xmin=-100, xmax=-50, ymax=50, ymin=30)
y <- setRes(y, res(x))
values(x) <- 1:ncell(x)
values(y) <- 1:ncell(y)
mr <- merge(x, y)
plot(mr)
# if you have many SpatRaster objects in a list
# you can use do.call:
s <- list(x, y)
# add arguments such as filename
# s$filename <- 'test.tif'
m <- do.call(merge, s)
# }
Run the code above in your browser using DataLab