我正在尝试使用 ffbase 在循环中对一个非常大的 ffdf 对象进行子集化,但我收到了错误消息:
Error in UseMethod("as.hi") : no applicable method for 'as.hi' applied to an object of
class "NULL"
我在具有大量可用内存的 ssh 上运行此代码。这是我要运行的代码:
# totalD is an ffdf with columns ID, TS, and TD, each with 288,133,589 rows. ID consists
# of integers. TS is a column of integer timestamps with second precision. TD is of type
# double. Uid3 is an integer vector consisting of the 1205 unique entries of totalD$ID.
# H_times creates a matrix of the sum of the entries in TD traveled in each hour
H_times <- function(totalD, Uid3) {
# hours is the number of unique hours of the experiment
hours <- length(unique(subset(totalD$TS, totalD$TS %% 3600 == 0)))-1
# bH is used as a counter in a the following loops
bH <- min(unique(subset(totalD$TS, totalD$TS %% 3600 == 0)))
# sum_D_matrix is the output
sum_D_matrix <- matrix(0, nrow = hours, ncol = length(Uid3))
for(i in 1:length(Uid3)) {
Bh <- bH
for(j in 1:hours) {
sum_D_matrix[j,i] <- sum(subset(totalD$TD, totalD$TS >= Bh & totalD$TS < (Bh + 3600) & totalD$ID == Uid3[i]))
Bh <- Bh + 3600
}
}
save(sum_D_matrix, file = "sum_D_matrix)
}
H_times(totalD, Uid3)
我试图实施 jwijffels 在这个问题的评论中建议的修复,但无济于事。提前致谢!