filePath <- system.file("external/", package="climetrics") # path to the dataset folder
pr <- rast(paste0(filePath,'/precip.tif'))
n <- readRDS(paste0(filePath,'/dates.rds')) # read corresoinding dates
head(n) # Dates corresponds to the layers in climate variables (pr, tmin, tmax, tmean)
####################
# use rts function in the rts package to make a raster time series:
pr.t <- rts(pr,n)
###########################
p12 <- apply.months(pr.t,'mean')
p12
plot(p12)
Run the code above in your browser using DataLab