【问题标题】:how to tell big.matrix to treat certain columns as vectors如何告诉 big.matrix 将某些列视为向量
【发布时间】:2013-05-02 00:29:32
【问题描述】:

我有一个包含许多不同值的字符变量的大数据集。我正在尝试将数据读取为big.matrix,然后使用biglm.big.matrix 构建线性模型。但是,由于big.matrix 会将所有字符向量转换为因子,因此字符标签将丢失。我决定在 R 之外为我的字符列创建一个查找表,并使用数字来表示 R 的不同级别。但是,我不知道如何告诉 big.matrix 这些列应该被视为因素而不是数字。请帮忙。

【问题讨论】:

    标签: r r-factor


    【解决方案1】:

    我对@9​​87654321@ 不是很熟悉,但你能用它的x 参数吗?来自?read.table.ffdf

    x
       NULL or an optional ffdf object to which the read records are appended. If this is provided,
       it defines crucial features that are otherwise determnined during the 'first' chunk of
       reading: vmodes, colnames, colClasses, sequence of predefined levels. In order to also read
       the first chunk into such predefined ffdf, an x with 1 row is treated special: instead of
       appending the first row will be overwritten. This is necessary because we cannot provide x 
       with zero rows (we cannot create ff vectors with zero elements).
    

    您可以将x中的对应列定义为具有给定水平的因子,然后将其用作模板。

    【讨论】:

    • 谢谢@mdsummer。当我回答这个问题时,标题是“如何使用 read.table.ffdf 将数值向量作为因子读取”
    • 哦,哎呀 - OP 现在也在询问 r-help
    猜你喜欢
    • 1970-01-01
    • 2019-11-19
    • 2012-03-25
    • 2012-06-22
    • 2019-06-27
    • 1970-01-01
    • 2017-01-08
    • 1970-01-01
    • 2010-09-26
    相关资源
    最近更新 更多