如何从ffdf对象中删除列? (R)

时间:2015-02-09 20:00:59

标签: r ff ffbase

我可以轻松删除ffdf对象的列吗?

library(ff);library(ffbase)    
irisdf=as.ffdf(iris)

如何仅包含Sepal.lengthSpecies列?

2 个答案:

答案 0 :(得分:2)

您可以尝试subset

中的ffbase
library(ffbase)
Subiris <- subset(irisdf, select=c('Sepal.Length', 'Species'))
dim(Subiris)
#[1] 150   2
colnames(Subiris)
#[1] "Sepal.Length" "Species"     

答案 1 :(得分:2)

library(ff)  
irisdf <- as.ffdf(iris)
filename(irisdf)
## Referencing the same data on disk (just making an new virtual ffdf)
example1 <- irisdf[setdiff(colnames(irisdf), c("Sepal.Length", "Species"))]
filename(example1)
## Referencing new data (copying)
example2 <- clone(irisdf[setdiff(colnames(irisdf), c("Sepal.Length", "Species"))])
filename(example2)