if (FALSE) {
file <- system.file("external/ndvi", package="rts")
ndvi <- rts(file) # read the ndvi time series from the specified file
ndvi
ep <- endpoints(ndvi,'years') # extract the end index on each year period
ndvi.y <- period.apply(ndvi,ep,mean) # apply the mean function on each year
ndvi.y
#---------
ep <- endpoints(ndvi,'quarters') # extract the end index on each quarter of a year
# a function:
f <- function(x) {
if (min(x) > 0.5) mean(x)
else 0
}
ndvi.q <- period.apply(ndvi,ep,f) # apply the function f on each quarter
}
Run the code above in your browser using DataLab