尝试将 .csv 文件读入 R 时出现“不完整的最后一行"警告 [英] 'Incomplete final line' warning when trying to read a .csv file into R

查看:56
本文介绍了尝试将 .csv 文件读入 R 时出现“不完整的最后一行"警告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将 .csv 文件读入 R 并使用此公式:

I'm trying to read a .csv file into R and upon using this formula:

pheasant<-read.table(file.choose(),header=TRUE,sep=",")

我收到此警告消息:

"incomplete final line found by readTableHeader on 'C:\Documents and Settings..."

我认为有几件事可能导致了这个警告,但不幸的是,我对 R 的了解不够,无法自己诊断问题,所以我想我会在这里发帖,希望其他人可以为我诊断!

There are a couple of things I thought may have caused this warning, but unfortunately I don't know enough about R to diagnose the problem myself so I thought I'd post here in the hope someone else can diagnose it for me!

  • .csv 文件最初是一个 Excel 文件,我将其保存为 .csv 格式
  • 该文件包含三列数据
  • 每个数据列的长度不同,即每列中有不同数量的值
  • 我想一次比较两列的均值(根据正态分布/非正态分布使用 t 检验或等价物),例如,在第 1 列值和第 2 列值之间进行 t 检验,然后第 1 列和第 3 列值的 t 检验等.

任何帮助或建议将不胜感激!

Any help or suggestions would be seriously appreciated!

推荐答案

该消息表明文件的最后一行没有以行尾 (EOL) 字符结尾(换行符 (\n) 或回车+换行符 (\r\n)).此消息的初衷是警告您该文件可能不完整;大多数数据文件都有一个 EOL 字符作为文件中的最后一个字符.

The message indicates that the last line of the file doesn't end with an End Of Line (EOL) character (linefeed (\n) or carriage return+linefeed (\r\n)). The original intention of this message was to warn you that the file may be incomplete; most datafiles have an EOL character as the very last character in the file.

补救方法很简单:

  1. 打开文件
  2. 导航到文件的最后一行
  3. 将光标放在该行的末尾
  4. 返回
  5. 保存文件

这篇关于尝试将 .csv 文件读入 R 时出现“不完整的最后一行"警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆