I want to calculate the persistence in the grid cell value of the time series raster stack. Here is a reproducible example and problem to be solved. library(raster)
G