gpt4 book ai didi

通过 read.big.matrix 在 R 中读取大数据

转载 作者:行者123 更新时间:2023-12-04 05:30:11 27 4
gpt4 key购买 nike

我正在使用 read.big.matrix 在 r 中读取维度为 3131875*5 的数据.我的数据有字符和数字列,包括日期变量。我应该使用的命令是

as1 <- read.big.matrix("C:/Documents and Settings/Arundhati.Mukherjee/My Documents/Arundhati/big data/MB07_Arundhati/sample2.txt",
header=TRUE,
backingfile="session.bin",
descriptorfile="session.desc",
type = NA)

但是 type = NA在这种情况下,在 R 中不被接受,我收到一个错误:
Error in filebacked.big.matrix(nrow = nrow, ncol = ncol, type = type,  : 
Problem creating filebacked matrix.
In addition: Warning messages:
1: In na.omit(as.integer(firstLineVals)) : NAs introduced by coercion
2: In na.omit(as.double(firstLineVals)) : NAs introduced by coercion
3: In read.big.matrix("C:/Documents and Settings/Arundhati.Mukherjee/My Documents/Arundhati/big data/MB07_Arundhati/sample2.txt", :
Because type was not specified, we chose double based on the first line of data.

我需要知道应该是什么 type这里。我尝试了类似 double 的选项但这给我带来了同样的错误。

请帮帮我。

最佳答案

来自 ?read.big.matrix :

Files must contain only one atomic type (all integer, for example).



因此,您将无法读取包含字符、数字、整数、日期等组合的数据。您可以对文件进行一些操作,例如使用不同的程序将字符变量转换为整数表示(例如转换为 R 中的因子)。

编辑:

关于 bigmemory website有一个使用python脚本预处理数据以将字符信息更改为整数的示例。该脚本是为特定数据集编写的,但也许您可以将其用作数据的指南。

关于通过 read.big.matrix 在 R 中读取大数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12725603/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com