The following correction has been added:
if (length(indices) == 1) {
composite[,, k] <- var[,, indices]
warning(paste("Composite", k, "has length 1 and pvalue is NA."))
} else {
composite[,,k] <- Mean1Dim(var[,, indices], posdim = 3, narm = TRUE)
}
The function can be tested with:
library(s2dverification)
source("./R/Composite.R")
var <- 1 : (5 * 6 * 7)
dim(var) <- c(x = 5, y = 6, time = 7)
occ <- c(1, rep (2, 6))
res <- Composite(var, occ)
str(res)