Compute global statistics, that is summarized values of an entire SpatRaster.
If stat is a true function, global will fail (gracefully) for very large SpatRasters, but it will in most cases work for functions that can be defined as by a character argument ("mean", "min", "max", or "sum").
If a function is used, it should accept a na.rm argument (or at least a ... argument)