- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个很大的制表符分隔数据表,我正尝试使用 data.table 包 fread 函数将其读入 R。但是,fread 遇到错误。如果我使用 read.delim,表格会被正确读入,但我不知道如何配置 fread 以使其正确处理数据。
为了寻找解决方案,我安装了 data.table 的开发版本,所以我目前正在运行 data.table v1.9.7,在 R v3.2.2 下,在 Ubuntu 15.10 上运行。
我已经从我的大表中将问题隔离到几行,你可以 download it here .
当我使用 fread 时:
> fread('problemRows.txt')
Error in fread("problemRows.txt") :
Expecting 8 cols, but line 3 contains text after processing all cols. It is very likely that this is due to one or more fields having embedded sep=',' and/or (unescaped) '\n' characters within unbalanced unescaped quotes. fread cannot handle such ambiguous cases and those lines may not have been read in as expected. Please read the section on quotes in ?fread.
我尝试使用 read.delim 使用的参数:
fread('problemRows.txt', sep="\t", quote="\"")
但我得到了同样的错误。
关于如何正确读入的任何想法?我不确定到底是什么问题。
谢谢!
最佳答案
最近的提交c1b7cda , fread
的引用逻辑在处理这种棘手的情况时变得更聪明了。有了这个:
require(data.table) # v1.9.7+
fread("my_file.txt")
应该可以正常工作。如果无法处理,错误消息现在也会提供更多信息。参见 #1462 .
如评论中所述,指定引号参数就可以了。
fread("my_file.txt", quote="")
关于r - 如何让 fread 像 read.delim 一样执行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34144314/
我有以下代码: int main() { char* pedal[20]; char* pedal2[20]; for (int i = 0; i < 20; i++)
我想用 in.wav 文件中的数据填充 hdr (结构)变量,并且我想复制 in 的前 64 个字节。 wav 文件转换为另一个文件 (out.wav)。 但是!当第二次使用fread()时,它开始从
我有一个由 1and1 托管的网站 - 他们没用!由于某种原因,他们提供的备份脚本不再有效,他们无法为我提供答案!所以我想我会自己写,这是我的代码: if (file_exists('backup
我正在尝试从文件中读取并将其复制到另一个文件。我正在网上查看一些代码,我似乎注意到有些人以这种方式声明 fread: fread (buffer, 1, 1000, src) 一些这样 fread (
当我是“男人的恐惧”时,我得到了: RETURN VALUE fread() and fwrite() return the number of items successfully read or
从文件中读取整数值时,覆盖率检查给出以下错误 调用函数“fread”会污染参数“readval” //coverity note: Calling function "fread" taints ar
为了更清楚地说明这一点,我将放置代码示例: $file = fopen('filename.ext', 'rb'); // Assume $pos has been declared // metho
尝试转换此 matlab 代码: fid = fopen([fpath, '/file.bin'],'rb'); content = fread(fid, 11,'single'); 我当前的尝试如下
假设我有: FILE* fp = fopen("myfile.bin", "r"); char something[30]; fread(something,sizeof(char)*30,1,fp)
fwrite 一个整数取决于字节序,但是有没有一种方法可以将一个整数 0x00000004 写入一个文件,这样无论它运行在什么机器上,它都可以始终被读取为 0x00000004。 一个想法是始终按照特
所以我尝试将此类 Matlab 代码转换为 C++: ss = 'file.mask' fp = fopen(ss, 'rb'); sx = fread(fp, 1, 'int32') sy = f
使用 C,可以使用函数 fread 来读取以 null 结尾的字符串吗? 我必须读取一个以 ip 开头的文件,该文件是 4 个无符号字符,后跟一个描述空终止字符串数的整数。之后,我需要读取字符串,直到
> fread('col1,col2\n') Empty data.table (0 rows) of 2 cols: col1,col2 > fread('col1,col2\n5,4') c
我正在尝试使用 data.table 将文件读入 R/fread .一些字段有前导零,我只想将数据作为字符读取并手动修复它们。但是我不知道如何将其传达给 fread .我正在尝试这个,它像往常一样分配
fread来自 data.table包一般可以在读取文件时自动确定列分隔符( sep )。 例如,这里fread自动检测 |作为列分隔符: library(data.table) fread(past
使用 fread,如何读取包含行名和列名的 CSV 文件。 我尝试了以下操作,但它没有正确读取行和列名称。 csv 文件看起来像(其中 C1、C2、C3 是列名,r1、r2、r3 是行名) input
我遇到了这样的文件: COL1 COL2 COL3 weqw asrg qerhqetjw weweg ethweth
我正在尝试使用 fread 读取表格。 txt 文件具有如下所示的文本: "No","Comment","Type" "0","he said:"wonderful|"","A" "1","Pr/ "
我正在尝试使用从 Apple 移动性报告生成的 csv,可以找到 here . 现在一切正常,我能够按预期获得 .csv,它看起来像这样的文字: csvtxt <- "geo_type,region,
我在 data.table (1.8.8, R 3.0.1) 中使用 fread 试图读取非常大的文件。 有问题的文件有 313 行和约 660 万列数字数据行,文件大小约为 12GB。这是具有 51
我是一名优秀的程序员,十分优秀!