Set number of columns with stack or brick or spatraster in rasterVis::levelplot

ggplot2plotrasterterravisualisation

If I have a spatraster with 6 layers, rasterVis::levelplot will give a 2 rows and 3 columns plot.

How can I change it to 3 rows and 2columns?

library(rasterVis)
library(terra)

f <- system.file("external/test.grd", package="raster")

rt1 <- rast(f)
rt2 <- rast(f)
rt3 <- rast(f)
rt4 <- rast(f)
rt5 <- rast(f)
rt6 <- rast(f)

rt <- c(rt1,rt2,rt3,rt4,rt5,rt6)

names(rt) <- LETTERS[1:6]

levelplot(rt)

enter image description here

Best Answer

You can do

levelplot(rt, layout = c(2, 3))