基本思想是这样的:我有一个很大的ffdf(大约 550 万 x 136 个字段)。我知道这个数据框中的一些列的所有列都是NA. 我如何找出哪些并适当地删除它们?
我的直觉是做类似的事情(假设df是ffdf):
apply(X=is.na(df[,1:136]), MARGIN = 2, FUN = sum)
这应该给我NA每列的计数向量,然后我可以找到哪些具有约 550 万个值,使用等NA删除它们。非常简单。df <- df[,-c(vector of columns)]
但是,apply给我一个错误。
Error: cannot allocate vector of size 21.6 Mb
In addition: Warning messages:
1: In `[.ff`(p, i2) :
Reached total allocation of 3889Mb: see help(memory.size)
2: In `[.ff`(p, i2) :
Reached total allocation of 3889Mb: see help(memory.size)
3: In `[.ff`(p, i2) :
Reached total allocation of 3889Mb: see help(memory.size)
4: In `[.ff`(p, i2) :
Reached total allocation of 3889Mb: see help(memory.size)
这告诉我apply无法处理这种大小的数据框。我可以使用任何替代方案吗?