R栅格时间序列分解错误
R raster timeseries decomposition error
我正在尝试分解每月时间序列堆栈(维度:336、221、74256、420)以获得随机分量。我正在使用以下内容:
tsfun <- function(x) {
my.ts = na.remove(ts(x, start=c(1982,1), frequency=12))
my.decomp = decompose(my.ts, type="multi")
my.exp = my.decomp$random
}
random <- calc(ras_in, fun=tsfun)
但我收到以下错误
.calcTest(x[1:5], fun, na.rm, forcefun, forceapply) 错误:
不能使用这个功能
有什么建议吗?
百万感谢
我认为你的函数无效。当我测试它时,我得到:
tsfun(1:24)
#Error in na.remove(ts(x, start = c(1982, 1), frequency = 12)) :
# could not find function "na.remove"
这是适合我的版本:
tsfun2 <- function(x) {
my.ts = na.omit(ts(x, start=c(1982,1), frequency=12))
decompose(my.ts, type="multi")$random
}
tsfun2(1:24)
# Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
#1982 NA NA NA NA NA NA 1 1 1 1 1 1
#1983 1 1 1 1 1 1 NA NA NA NA NA NA
我正在尝试分解每月时间序列堆栈(维度:336、221、74256、420)以获得随机分量。我正在使用以下内容:
tsfun <- function(x) {
my.ts = na.remove(ts(x, start=c(1982,1), frequency=12))
my.decomp = decompose(my.ts, type="multi")
my.exp = my.decomp$random
}
random <- calc(ras_in, fun=tsfun)
但我收到以下错误
.calcTest(x[1:5], fun, na.rm, forcefun, forceapply) 错误: 不能使用这个功能
有什么建议吗? 百万感谢
我认为你的函数无效。当我测试它时,我得到:
tsfun(1:24)
#Error in na.remove(ts(x, start = c(1982, 1), frequency = 12)) :
# could not find function "na.remove"
这是适合我的版本:
tsfun2 <- function(x) {
my.ts = na.omit(ts(x, start=c(1982,1), frequency=12))
decompose(my.ts, type="multi")$random
}
tsfun2(1:24)
# Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
#1982 NA NA NA NA NA NA 1 1 1 1 1 1
#1983 1 1 1 1 1 1 NA NA NA NA NA NA