R原始文本文件读取后缺少行

时间:2016-01-28 14:27:33

标签: r text

我目前正在研究一些文本挖掘并尝试使用原始文本读取平面文件,但是当我读取该文件时,我在读取后丢失了超过一半的行。该文件看起来与此类似;

ddjkfj; this is a raw line of text ? fjpflij 
jfioej33 this is another line of text jdkfjd
etc.

我正在尝试使用此方法读入

data <- read.table('text.txt',sep='\n',fill=T)

如果没有跳过或加入线条,我该怎么读?

1 个答案:

答案 0 :(得分:5)

您可以尝试使用readLines:

lines <- readLines('fileToRead.txt')
lines
[1] "ddjkfj; this is a raw line of text ? fjpflij "
[2] "jfioej33 this is another line of text jdkfjd"