I have a time series of raster images read as a raster stack using raster package in R where each raster has the calculated value ranges from 0 - 100. However, when there is cloud cover those pixels are coded as 255. I want to calculate mean of the stacked raster but exclude those pixel values in the calculation of the mean i.e. 255
The code I am using is given below and any guidance is greatly appreciated.
setwd("D:\\MODIS_data")
files_tiff <- dir(pattern = "BS")
test <- stack(files_tiff)
## Mean
rs1_mean <- calc(test, mean)
plot(rs1_mean)