X=runif(120, min = 0, max = 100) # 10-year monthly data
thre=-1 # specify the threshold value
fit<-SDI(X,ts=3) # Compute the univariate drought index, such as SPI
z=matrix(t(fit$SDI),ncol=1) # Reshape the matrix to a vector
Res <- RunDS(z, thre) # Compute the duration and severity
Run the code above in your browser using DataLab