fread EOF 而不是分隔符

2024-01-31

我正在尝试用 fread 读取一个大文件,但我猜文件的布局有些混乱。

如果我尝试读取文件

data = fread(input = "../data.txt", sep = "\t")

在此文件上(我只是选择了有错误的行以及前后的一些内容):

ID  imdbID  Title   Year    Rating  Runtime Genre   Released    Director    Writer  Cast    Metacritic  imdbRating  imdbVotes   Poster  Plot    FullPlot    Language    Country Awards  lastUpdated Type
683 tt0000683   The Fatal Hour  1908        14 min  Short, Crime    1908-08-18  D.W. Griffith   D.W. Griffith   George Gebhardt, Harry Solter, Linda Arvidson, Florence Auer        5.9 26      Pong Lee, a Mephistophelian, saffron-skinned varlet, has for some time carried on this atrocious female white slave traffic, in which sinister business he was assisted by a stygian whelp, ... Pong Lee, a Mephistophelian, saffron-skinned varlet, has for some time carried on this atrocious female white slave traffic, in which sinister business he was assisted by a stygian whelp, by name Hendricks. Pong writes Hendricks that he has need for five young girls, and so Hendricks sets out to secure them. Visiting a rural district, he has no trouble, by his glib, affable manner, in gaining the confidence of several young and pretty girls. Pong is on hand with a closed carriage to bag the prey. One of the girls, as she is seized, emits a yell that alarms the neighborhood and brings to the scene several policemen and a couple of detectives, who have long been on the lookout for these caitiffs. The Chinese get away with the carriage, however, and Hendricks by subterfuge throws the police on the wrong scent. One of the detectives is a woman, and possessed of shrewd powers of deduction, hence does not swallow the bald story of the villain, and exercises her natural acumen with success. She shadows Hendricks, and by means of a flirtation inveigles him to a restaurant, where she succeeds in doping his drink. He falls asleep and she secures the letter written by Pong, which discloses the hiding place of the Chinaman. This she immediately telephones to the police, and while so doing Hendricks awakes and starts off to warn his friends. He arrives at the old deserted house ahead of the police, but escape is impossible, so the police rescue the girls, but fail to secure Pong and Hendricks, who afterwards seize the girl detective, and taking her to the house, tie her to a post and arrange a large pistol on the face of a clock in such a way that when the hands point to twelve the gun is fired and the girl will receive the charge. Twenty minutes are allowed for them to get away, for the hands are now indicating 11:40. Certain death seems to be her fate, and would have been had not an accident disclosed her plight. Hendricks after leaving the place is thrown by a street car, and this serves to discover his identity, so he is captured and a wild ride is made to the house in which the poor girl is incarcerated. This incident is shown in alternate scenes. There is the helpless girl, with the clock ticking its way towards her destruction, and out on the road is the carriage, tearing along at breakneck speed to the rescue, arriving just in time to get her safely out of range of the pistol as it goes off. In conclusion we can promise this to be an exceedingly thrilling film, of more than ordinary interest.    English USA     2015-10-24 01:44:09.623000000   movie
684 tt0000684   Father Gets in the Game 1908        10 min  Short, Comedy   1908-10-10  D.W. Griffith   D.W. Griffith   Mack Sennett, Harry Solter, George Gebhardt, Linda Arvidson     5.1 39      "You have got to keep up with the bandwagon or quit." This never impressed old Wilkins so forcibly as when his son and daughter give him the go-by, stamping him as a "has-been," and away ...  "You have got to keep up with the bandwagon or quit." This never impressed old Wilkins so forcibly as when his son and daughter give him the go-by, stamping him as a "has-been," and away out of the game. Even Mrs. Wilkins, who is as vivacious as a widow, snubs him. He keenly feels his condition and resolves to alter it. With this in view, he enlists the services of Professor Dyem, the celebrated Dermatologist and Tonsorial Artist. After a session with the Professor, beheld the transmogrified Wilkins. What a change! Shorn of his grizzly beard, his locks raven, complexion florid, eye clear and step elastic, he views himself in the mirror. He hardly recognizes himself. In fact, it requires his valet to convince him that he is he. "Am I in it? Well. I guess. If I don't keep up with and even beat that bandwagon by a city block, my name is not Pill Wilkins." He sallies forth and makes for the park. The first person he encounters is his wife. He approaches her in elation, but she mistakes him for an impudent masher and he receives the weight of her parasol over his head for his trouble. The next one he meets is his daughter. She is seated on a bench, waiting for Charley. He takes a seat beside her and when he tries to make himself known she draws herself up to full height and with a blow sends him backward over the bench onto the grass. Well, he changes his tactics, and gets reckless. Along comes his son with his best girl, so he decides to win her out for spite. Now this young lady has a sensitive pneumogastric nerve, and when he sits beside her on the bench and slyly suggests a cold bottle and a hot bird, she is "his'n." This is done so coolly and so quickly, that young Wilkins, who, of course, does not recognize his respected papa, is speechless with rage. He follows them, however, to the café, where his intrusion is resented and he is rudely thrown from the place. At the Wilkins' domicile there is an indignation meeting. Mother, daughter and son all rush in to relate their experiences to father. He is not to be found. Suddenly a hilarious individual enters. "'Tis he, the insulter: a drunk and disorderly." They are about to have him thrown out when the valet comes to his rescue and explains that the jubilant gentleman is no other than their dear papa, who has not only caught up with the bandwagon, but is sitting on the seat with the driver. They all gasp in surprise, and young Wilkins takes a wreath of laurel from a statue and places it on old Wilkins' brow, saying: "Pop, you are the candy."    English USA     2015-10-02 04:59:48.643000000   movie
685 tt0000685   The Feud and the Turkey 1908        15 min  Short, Drama, Romance   1908-12-08  D.W. Griffith   D.W. Griffith   Harry Solter, Linda Arvidson, Arthur V. Johnson, Robert Harron      5.8 13      The Wilkinsons and Caulfields, owing to a trivial dispute, had been at loggerheads for years and as time went on the feeling became more bitter, until they even forbade their children ... The Wilkinsons and Caulfields, owing to a trivial dispute, had been at loggerheads for years and as time went on the feeling became more bitter, until they even forbade their children playing together. The little ones, however, in their childish innocence, could not appreciate the odium of their elders, and Bobby Wilkinson and Nellie Caulfield became child lovers. This incensed Colonel Wilkinson, who tore the children apart, ordered Bobby never to be seen in her company again. The Colonel's action ignited the ire of the Caulfields and a furious conflict ensued, resulting in the shooting to death of George, the Colonel's youngest son, a boy of fourteen. From that time on the clans kept strictly to themselves. But love knows no clannishness, and, despite family hatred, Bob and Nellie remained lovers. After ten years, driven to desperation by this apparently insurmountable barrier, they elope and are married. Bob decides to brave the storm of his father's anger and present his wife, but the old Colonel drives him from the house, disowning him. Old Aunt Dinah and Uncle Daniel, the colored servants, were so attached to the young folks that they go with them. Two years later we find the little family, now increased by an infant son, having a hard of it. It is Christmas morning and no turkey for dinner. Old Aunt Dinah, believing in the efficacy of prayer, gets down on her knees in the kitchen to ask the good Lord to send them a bird. Uncle Daniel, touched by this demonstration of faith, takes a gun and determines to get a turkey at any hazard. Over the hills he goes, but his journey is hopelessly fruitless until he comes to the rear of the Colonel's house. Tillie, the cook, has just hung a fat turkey on a post outside the kitchen door. When Daniel sees it he can't resist the temptation. Back home he hustles and finds Dinah still at prayer, he lays the fowl on the floor beside her and sneaks out. When Dinah sees it she surely thinks it was due to her prayers. Well, the turkey is cooked and an old-fashioned Christmas anticipated. Meanwhile the Colonel has discovered his loss and tracks the thief to Bob's estate. Entering, a tragedy seems inevitable, but when the old Colonel sees the young one, his grandson, in the cradle, his heart goes out to it and the feud ends then and there. All hands sit down and enjoy a real Merry Christmas dinner. English USA     2015-08-29 00:33:15.610000000   movie
686 tt0000686   Fiestas del carnaval de 1908 en Barcelona   1908            Documentary, Short      Fructuós Gelabert   Fructuós Gelabert                                   Spain       2015-11-09 14:24:29.583000000   movie

我收到此错误:

>     Error in fread(input = "../data.txt", sep="\t"  :    Expected sep ('  ') but new line, EOF (or other
> non printing character) ends field 20 when detecting types (   first):
> 684   tt0000684   Father Gets in the Game 1908        10 min  Short,
> Comedy    1908-10-10  D.W. Griffith   D.W. Griffith   Mack Sennett, Harry
> Solter, George Gebhardt, Linda Arvidson       5.1 39      "You have got to keep
> up with the bandwagon or quit." This never impressed old Wilkins so
> forcibly as when his son and daughter give him the go-by, stamping him
> as a "has-been," and away ...     "You have got to keep up with the
> bandwagon or quit." This never impressed old Wilkins so forcibly as
> when his son and daughter give him the go-by, stamping him as a
> "has-been," and away out of the game. Even Mrs. Wilkins, who is as
> vivacious as a widow, snubs him. He keenly feels his condition and
> resolves to alter it. With this in view, he enlists the services of
> Professor Dyem, the celebrated Dermatologist and Tonsorial Artist.
> After a session with the Professor, beheld the transmogrified Wilkins.
> W

我该如何解决它?


我不能 100% 确定您的数据中存在什么错误,但请尝试运行代码

data = fread(input = "../data.txt", sep = "\t", fill = TRUE)

在 fread 选项中。我也遇到了类似的错误,而且 fread 似乎无法识别我的列间隔。将 fill 设置为 true 允许 fread 填充任何丢失的数据 - 至少这样您可以检查结果数据框并找出奇怪的地方。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

fread EOF 而不是分隔符 的相关文章

  • 跟踪循环迭代

    抛硬币 成功 你赢100 否则你输50 你会一直玩 直到你口袋里有钱a 的价值如何a在任何迭代中都被存储 a lt 100 while a gt 0 if rbinom 1 1 0 5 1 a lt a 100 else a lt a 50
  • randomForest 包在删除一个预测类时的奇怪行为

    我正在运行一个随机森林模型 它产生的结果从统计角度来看对我来说完全没有意义 因此我确信有些东西mustrandomForest 包的代码出现错误 至少在模型的本次迭代中 预测 左侧变量是具有 3 种可能结果的政党 ID 民主党 独立党 共和
  • 如何在 Caret 中绘制随机森林(护林员)树

    我生成了如下所示的随机森林树 并尝试绘制它 但出现错误 我在哪里犯了错误 我怎样才能以正确的方式绘制它 Actmodel lt train Activity Section Author data CB1 method ranger trC
  • R、Rcpp 与 Armadillo 中矩阵 rowSums() 与 colSums() 的效率

    背景 来自 R 编程 我正在扩展到 C C 形式的编译代码Rcpp 作为循环交换 以及一般的 C C 效果的实践练习 我实现了 R 的等效项rowSums and colSums 矩阵的函数Rcpp 我知道它们以 Rcpp 糖的形式存在 并
  • R中的字典数据结构

    在 R 中 我有 例如 gt foo lt list a 1 b 2 c 3 如果我输入foo I get a 1 1 b 1 2 c 1 3 我怎样才能看透foo仅获取 键 列表 在这种情况下 a b c R 列表可以具有命名元素 因此可
  • R - 计算 bin 中特定值的数量

    我有一个如下所示的数据框 df Value lt c 1 1 0 2 1 3 4 0 0 1 2 0 3 0 4 5 2 3 0 6 Sl lt c 1 20 df lt data frame Sl Value gt df Sl Value
  • Quantmod 的简单功能不再起作用

    我明天要交论文 我收到了一条关于 quantmod 的非常奇怪的错误消息 这是我在过去几周使用这个包时从未遇到过的 我无法导入特定于道琼斯指数 DJI 的数据 我收到以下错误消息 getSymbols DJI src yahoo from
  • 使用officer R导出时如何提高ggplots的分辨率

    我想将图表导出到 PPT 并使用Officer 包来实现相同的目的 但是 图表的默认分辨率较低 我想更改它 我目前正在使用以下电话 ph with gg p1 type chart res 1200 其中 p1 是 ggplot 对象 运行
  • R 闪亮仪表板中的动态重复条件面板

    我正在尝试创建一个动态条件面板 所以我的条件如下 在用户界面中输入 selectInput inpt Input Number seq 1 50 1 selectize FALSE 我的条件面板 UI 输入是 conditionalPane
  • 实现 XGboost 自定义目标函数

    我正在尝试使用 XGboost 实现自定义目标函数 在 R 中 但我也使用 python 所以有关 python 的任何反馈也很好 我创建了一个返回梯度和粗麻布的函数 它工作正常 但是当我尝试运行 xgb train 时它不起作用 然后 我
  • 绘制 Cox 回归的 Kaplan-Meier 图

    我使用 R 中的以下代码设置了一个 Cox 比例风险模型来预测死亡率 添加协变量 A B 和 C 只是为了避免混淆 即年龄 性别 种族 但我们真正对预测变量 X 感兴趣 X 是一个连续变量 cox model lt coxph Surv t
  • R ggplot 中的柯尔莫哥洛夫-斯米尔诺夫图

    我正在尝试在 r 中绘制 KS 图 一切似乎都很顺利 除了我只能使用颜色来可视化两个不同的样本而不是线型这一事实 我已经尝试过以下方法 sample1 lt SD13009 sample2 lt SD13009PB group lt c r
  • R - 重塑 - 熔化错误

    我正在尝试融化数据框 但出现了这个奇怪的错误 有什么想法吗 str zx7 data frame 519 obs of 5 variables calday new Date format 2011 01 03 2011 01 04 201
  • 在 Shiny 中显示反应式 htmlTable 表格

    我正在制作我的第一个 Shiny 应用程序 但找不到任何有关如何显示使用 htmlTable 包创建的表格的示例 我基本上想在按下按钮时创建一个表格并显示它 Shiny 显示 html 代码而不是表格 我不知道用什么替换服务器部分中的 re
  • 如何按定义的顺序将图像合并到一个文件中

    我有大约 100 张图像 png 我不想手动执行此操作 而是希望将它们按照定义的顺序 基于文件名 并排放置在一个 pdf 中 每行 12 个图像 有人有什么建议吗 我按照下面托马斯告诉我的方法尝试了 它把它们贴在旁边有一个黑边 我怎样才能去
  • R在Windows平台Rstudio上打印data.frames中的UTF-8代码

    当数据框中存在UTF 8字符时 将无法正常显示 例如 以下内容是正确的 gt U6731 1 朱 但是当我将其放入数据框中并打印出来时 它是 gt data frame x U6731 x 1
  • 使用选定因子水平的值向 ggplot-barchart 添加水平线

    在这个情节中 df lt data frame factor as factor c rep A 3 rep B 3 Treatment c rep c A B C 2 values runif 6 0 1 ggplot df aes Tr
  • 增加雷达图中长轴标签的空间

    我想创建一个雷达图ggirahExtra ggRadar 问题是我的标签很长并且被剪掉了 我想我可以通过添加在标签和绘图之间创建更多空间margin margin 0 0 2 0 cm to element text in axis tex
  • 要在子集中显示的非数字条目的维恩图

    我有以下数据框 SET1 SET2 SET3 par1 par2 par1 par2 par3 par2 par3 par4 par5 我想制作一个维恩图 其中所有这些 parX 元素都显示在各自的子集中 即作为标签 而不仅仅是重叠元素的数
  • 当设置 coord_fixed 时,ggplot/shiny 中的鼠标悬停坐标是错误的

    我正在使用问题中的答案 当您将鼠标悬停在闪亮的 ggplot 上时出现工具提示 https stackoverflow com questions 27965931 tooltip when you mouseover a ggplot o

随机推荐

  • 如何仅使用 XAML 而不使用隐藏代码对 ListBox 进行排序?

    我需要对 a 中的字符串进行排序ListBox 但它通过另一个组件绑定到视图模型DataContext 所以我无法直接在 XAML 中实例化视图模型 如这个例子 http www galasoft ch mydotnet articles
  • 如何在 MS sql server 上的列中查找和删除字母

    我有一列字母数字 ID 我们称之为 IDS id 只能是数字 但其中一些包含杂散字符 例如 IDS 012345A 23456789AF 789789 我只想将它们转换为数字 所以输出将是 IDS 012345 23456789 78978
  • 如何避免C++中operator==实现中的错误?

    我经常有提供简单的逐个成员比较的类 class ApplicationSettings public bool operator const ApplicationSettings other const bool operator con
  • Python-评估字符串中的数学表达式[重复]

    这个问题在这里已经有答案了 我有一个关于字符串内数学表达式求值的问题 例如我的字符串如下 my str I have 6 2 3 apples 我想知道如何评估这个字符串并得到以下结果 I have 30 apples 有什么办法可以做到这
  • “调用目标已引发异常”错误 (mscorlib)

    我有一个用 ASP Net 2 0 开发的网站 抛出错误 Exception has been thrown by the target of an invocation 在生产环境中 它并没有在开发中抛出这个错误 源是 mscorlib
  • C++ 迭代器和循环优化

    我看到很多 C 代码看起来像这样 for const iterator it list begin const iterator ite list end it ite it 与更简洁的版本相反 for const iterator it
  • 将 bsTooltip 框的颜色更改为闪亮

    是否可以通过以下方式来设计工具提示框的美观性 bsTooltip闪亮的 我已经寻找答案 但就工具提示而言 所有关于美观的调整似乎仅针对宽度 即这个问题 https stackoverflow com questions 58320525 s
  • CSS“下划线”文本部分

    如何为文本添加下划线以获得与 测试 下看到的相同效果 我尝试将 TEST 封装在span并添加绝对 after withposition absolute 但我认为这不是正确的方法 并没有得到预期的结果 这是 HTML h1 class w
  • 使用 getevent 在已 root 的 Android 手机上拒绝权限

    我有非常简单的代码如下 Override public void onClick View v Log i MyApp Started try Process processStart Runtime getRuntime exec su
  • 如何使用右/左在sqldf中分割变量,如left(x,n)

    R 中是否有不同的函数可以用来获得与 SQL 中左函数或右函数相同的结果 例如 以下 SQL 查询将给出列的前 6 个字符 select left x 6 from table 但是 当我在 sqldf 中尝试这样做时 如下所示 sqldf
  • 如何计算图像的直方图?

    我该如何解决以下错误 import cv2 img cv2 imread home monojit Desktop crop jpg hsv cv2 cvtColor img cv2 COLOR BGR2HSV hist cv2 calcH
  • R 是否有依赖于系统的功能?

    我的同事希望确保我们在 R 中的工作独立于平台 特别是代码可以在 Linux Mac 和 Windows 上运行 并且在一个系统上创建的文件可以在其他系统上运行 由于这个问题之前在我的团队中出现过 我希望得到一个笼统的答案 这将使我更容易自
  • 一段时间后,条形码扫描仪抛出 java.lang.UnsatisfiedLinkError

    我有一个使用新的 Android 视觉库的条形码扫描仪 它在我的设备和其他几个设备上完美运行 但突然它停止工作 我在日志中看到以下异常 No implementation found for com google android gms v
  • Unity中如何设置文本的字体大小?

    如何使标签中的字体变大 我用这个函数来显示文本 function OnGUI GUI color Color green GUI Label Rect 500 350 200 50 Lose 结果是 我怎样才能把这个文字变大 只需创建一个合
  • 如何从我的程序中列出 Internet Explorer 使用的插件 (BHO)?

    我需要在我的 Win32 独立程序中检索 当前安装的 Internet Explorer 加载项列表 浏览器帮助程序对象 以及 如果可能 它们的启用 禁用状态 由于反间谍软件程序 或例如Autoruns https technet micr
  • go lang中按不同维度对点(结构)进行排序

    我有一个 Points 类型的多维点列表 我已经实施了sort Sort界面 现在可以排序y value e g type Points Point func points Points Len int return len points
  • 当视图不与模型交互时,这就是 MVC 吗?

    我设计了一个 MVC 在 NET 中 其中视图没有到模型的链接 它只知道控制器 传统的 MVC 模式的所有部分都相互通信 就我而言 控制器基本上是一个调解者 这会将任何异常或逻辑排除在视图之外 它对模型的依赖性为零 这不再是 MVC 了吗
  • 使用 Three.js 单击网格获取像素的颜色值

    我正在使用 Three js 的最新版本 我得到了一个带有 2D 网格和渐变颜色的场景 颜色取决于分配给每个顶点的值 我想通过用鼠标单击渐变的每个点来获取它的值 通过获取颜色 并对我的值进行一些数学计算 我尝试使用这样的系统 因为它在这里工
  • 使用toggleClass更改类后的jQuery事件

    我对 jQuery 和toggleClass 有疑问 我想创建一个 div 单击按钮即可关闭 按钮发生变化 当我再次单击此按钮时 div 将再次打开 问题是 当我单击按钮时 div 关闭并且按钮的类发生变化 这很好 但现在 当我单击新类的按
  • fread EOF 而不是分隔符

    我正在尝试用 fread 读取一个大文件 但我猜文件的布局有些混乱 如果我尝试读取文件 data fread input data txt sep t 在此文件上 我只是选择了有错误的行以及前后的一些内容 ID imdbID Title Y