5183 2

[问答] 请教用read.table读取TXT文件的问题 [推广有奖]

  • 0关注
  • 0粉丝

高中生

32%

还不是VIP/贵宾

-

威望
0
论坛币
10 个
通用积分
0
学术水平
0 点
热心指数
0 点
信用等级
0 点
经验
354 点
帖子
14
精华
0
在线时间
26 小时
注册时间
2017-6-4
最后登录
2017-11-19

楼主
淡淡的风2017 发表于 2017-6-4 20:16:56 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币
请问[size=14.3999996185303px]read.table读取TXT文件的几个问题:
1、显示出来的数据,[size=14.3999996185303px]为什么在每一段前都有大段空白行?
代码如下:
setwd("D:/study/my R")
read.table("news.txt",header=F,strip.white = TRUE, blank.lines.skip = TRUE)

原本TXT文件是这样的:
1.jpg

但是实际运行后在RStudio的Console中却是这样的:
2.jpg

2、为什么一定要在TXT文件的最后一行有回车,否则就会报如下错误:
Warning message:
In read.table("news.txt", header = F, strip.white = TRUE, blank.lines.skip = TRUE) :
  incomplete final line found by readTableHeader on 'news.txt'


二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

关键词:Table READ ABLE tab ABL TXT

沙发
yzharold 发表于 2017-6-6 00:23:38
it is text data, and you should try to use scan function instead of read.table, or you could try to use read.delim instead of read.table

The space appeared in your data read in might be due to the fact that the file was created in windows, the space will be different from the regular space in ASCII coding of plain text. The experiment would be try to look at your file in a Linux/Mac system.

Hopefully, it will help you.

藤椅
淡淡的风2017 发表于 2017-6-6 22:42:23
Thanks for your help.

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2026-1-24 18:55