With a moderately large data and unspecified twindow, tmpInd will have countless rows, and apply on it is literally time-consuming. I adapt it for a vectorized computation and the efficiency is much improved.
data[indSp[,1],1] extracts only one column. For a data.frame, the default is to drop if only one column is left, and the result reduces to a vector. However, for a tibble, it's not the default. data[indSp[,1],1] is still a tibble, and hence passing a tibble into mean returns NA. I add drop=TRUE to coerce tibble to drop.
https://github.com/r-spatial/gstat/blob/8335d8e2fb1a16b02d256148d502a7edcff9142a/R/variogramST.R#L234
With a moderately large data and unspecified
twindow
,tmpInd
will have countless rows, andapply
on it is literally time-consuming. I adapt it for a vectorized computation and the efficiency is much improved.https://github.com/r-spatial/gstat/blob/8335d8e2fb1a16b02d256148d502a7edcff9142a/R/variogramST.R#L255-L256
data[indSp[,1],1]
extracts only one column. For adata.frame
, the default is to drop if only one column is left, and the result reduces to a vector. However, for atibble
, it's not the default.data[indSp[,1],1]
is still atibble
, and hence passing atibble
intomean
returns NA. I adddrop=TRUE
to coercetibble
to drop.