library(terra)
a=rast(nrows=10,ncols=10,vals=1:100)
b=rast(nrows=10,ncols=10,vals=1:100)
c=rast(nrows=10,ncols=10,vals=1:100)
test <- c(a,b,c)
for (i in 1:3)
{
r=test[[i]]
writeRaster(r,paste0("E:/test",i,'.tif'))
}
This is my way to do it. I want to know is there a easier way to do it?