https://github.com/cran/spacetime
Tip revision: a1dd8d78dccd4b48b084ac0d2256c6da81a0c6f3 authored by Edzer Pebesma on 05 December 2023, 21:20:03 UTC
version 1.3-1
version 1.3-1
Tip revision: a1dd8d7
apply.R
# or is this too trivial to provide?
STapply = function(X, MARGIN, FUN, ...) {
stopifnot(class(X) == "STFDF")
if (MARGIN == "space" || MARGIN == 1)
FOREACHSPACEapply(X, FUN, ...)
else if (MARGIN == "time" || MARGIN == 2)
FOREACHTIMEapply(X, FUN, ...)
else stop("MARGIN should be 1 (space) or 2 (time)")
}
FOREACHSPACEapply = function(X, FUN, ...) {
ret = lapply(1:length(X@sp), function(i) FUN(X[i,], ...))
#STFDF(X@sp, ret[[1]], do.call(rbind, ret))
}
FOREACHTIMEapply = function(X, FUN, ...) {
ret = lapply(1:nrow(X@time), function(i) FUN(X[,i], ...))
}