删除ff包行 [英] delete rows ff package

查看:75
本文介绍了删除ff包行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一段时间以来,我一直在使用ff包来处理大数据.我处理过的R对象大约有130.000.000行和14列.这些列中的两列,温度"和降水量"缺少值"NA",因此我需要删除这些行,以便继续进行工作. 我一直在尝试像在普通R对象中那样进行操作:

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

有人能删除ffdf对象中的行吗? 我将不胜感激.

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

推荐答案

在ff中无法基于逻辑ff_vector进行索引,您需要提供ff个整数的向量.这就是错误消息试图告诉您的内容.所以你可以这样子设置

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, ]

或(使用ffbase 6.3版)

or (using version 6.3 of ffbase)

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

这篇关于删除ff包行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆