20

data.table( 2016年11月25日の新しいバージョン以降、質問はもう関係ありません-以下の受け入れられた回答を参照してください)

だから、真ん中にいくつかの空の行があるテーブルがあります。で開こうとするとfread、 と言って止まりますStopped reading at empty line 10006, but text exists afterwards (discarded)。データファイルを変更せずにこれを回避する方法はありますか?

4

3 に答える 3

5

Windowsfindstrコマンドを使用して、空行を取り除くことができます。

サンプルファイル「Data.txt」。

1,a

2,b
3,c
4,a


5,b

6,c

エラーを再現します。

> dt <- fread("Data.txt")
Warning message:
In fread("Data.txt") :
Stopped reading at empty line 6 of file, but text exists afterwards (discarded): 5,b

ただし、Windowsfindstrを で直接使用する場合は機能しfreadます。

> require(data.table)
> dt <- fread('findstr "." Data.txt')

# > dt
#    V1 V2
# 1:  1  a
# 2:  2  b
# 3:  3  c
# 4:  4  a
# 5:  5  b
# 6:  6  c
于 2015-03-16T01:04:10.843 に答える