NA in data gives wrong results for Clim()
the handling of NA in Clim
is wrong somehow.
1st example - no NA in data. Clim()
and apply()
give same results:
d <- rnorm(15)
var <- array(data=d,dim=c(1,3,5,1,1,1))
names(dim(var)) <- c("dat","memb","sdate","time","lat","lon")
##
print(Clim(var,var,memb=TRUE)$clim_exp)
print(apply(var[1,,1:5,1,1,1],1,mean))
2nd example - some random NA in data. Clim()
and apply()
DO NOT give same results. Instead Clim()
just outputs some elements of the input data:
d <- rnorm(15)
d[c(1,2,5,6,7,14)] <- NA
var <- array(data=d,dim=c(1,3,5,1,1,1))
names(dim(var)) <- c("dat","memb","sdate","time","lat","lon")
##
print(Clim(var,var,memb=TRUE)$clim_exp)
print(apply(var[1,,1:5,1,1,1],1,mean,na.rm=T))
##
## result of Clim() is identical to
print(var[1,1:3,4,1,1,1])
if memb=FALSE
the results are also incorrect
Thanks a lot!