How to use apply or sapply or lapply with ffdf?

后端 未结 1 1874
野趣味
野趣味 2021-01-03 16:34

Is there a way to use an apply type construct directly to the columns of a ffdf object? I am trying to count the NAs in each column without having to turn it into a standar

相关标签:
1条回答
  • 2021-01-03 17:02

    An ffdf is basically a list with elements "virtual", "physical", "row.names". If you do an lapply over the physical element, you have what you want.

    require(ffbase)
    myffdf <- as.ffdf(iris)
    lapply(physical(myffdf), FUN=function(x) sum(is.na(x)))
    

    As is.na and sum is generic, this will basically use is.na.ff and sum.ff from package ffbase such that data is loaded into RAM chunkwise according to what your computer can handle.

    0 讨论(0)
提交回复
热议问题