Apply a terra function that takes only a single layer and returns a SpatRaster to all layers of a SpatRaster
Useful links