【问题标题】:How to DROP columns from ffdf object ? (R)如何从 ffdf 对象中删除列? (右)
【发布时间】:2015-02-09 20:00:58
【问题描述】:

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

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

如何只包含Sepal.lengthSpecies 列?

【问题讨论】:

    标签: r ff ffbase


    【解决方案1】:

    你可以试试 subsetffbase

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

    【讨论】:

    • 它是在原地工作还是在 irisdf 对象上需要双倍的内存?
    【解决方案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)
    

    【讨论】:

    • 我选择这个答案,因为它更深
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-08-03
    • 1970-01-01
    • 2021-04-12
    • 1970-01-01
    相关资源
    最近更新 更多