filePath <- system.file("external/", package="climetrics") # path to the dataset folder
pr <- rast(paste0(filePath,'/precip.tif'))
tmean <- rast(paste0(filePath,'/tmean.tif'))
n <- readRDS(paste0(filePath,'/dates.rds')) # corresoinding dates
head(n) # Dates corresponds to the layers in climate variables
####################
# use rts function in the rts package to make a raster time series:
pr.t <- rts(pr,n)
tmean.t <- rts(tmean,n)
###########################
dv <- dVelocity(pr.t,tmean.t,t1='1991/2000',t2='2010/2020')
plot(dv)
Run the code above in your browser using DataLab