delete rows ff package

走远了吗. 提交于 2019-12-03 14:41:39

问题


Since a while now I´ve been using ff package in order to work with big data. The R object I´ve worked with has about 130.000.000 rows and 14 columns. Two of those columns, Temperature and Precipitation have missing values “NA” so I need to delete those rows in order to move forward with my work. I´ve been trying to do it like I would in a normal R object:

data<-data[!is.na(data$temp),]

But I keep getting an error:

Error: vmode(index) == "integer" is not TRUE

Does anyone have been able to delete rows in a ffdf object? I´d appreciate any help.


回答1:


Indexing based on a logical ff_vector is not possible in ff, you need to supply a vector of ff integers. That is what the error message is trying to tell you. So you can do the subsetting like this

require(ffbase)
idx <- !is.na(data$temp)
idx <- ffwhich(idx, idx == TRUE)
data <- data[idx, ]

or (using version 6.3 of ffbase)

require(ffbase)
data <- subset(data, !is.na(temp))


来源:https://stackoverflow.com/questions/13806353/delete-rows-ff-package

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!