全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 R语言论坛
5083 2
2017-06-04
请问[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'


二维码

扫码加我 拉你入群

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

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

全部回复
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-6-6 22:42:23
Thanks for your help.
二维码

扫码加我 拉你入群

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

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

相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群