您也可以讀取文件到內存中,
> buffer <- readLines ("tmp/file")
> buffer
[1] "0 0 0" "0 0 0"
[3] "" ""
[5] "54077 184965 81.25" "54266 184776 81.25"
[7] "" ""
[9] "65130 199986 82.1705426356589" "65513 199600 82.1705426356589"
刪除或進程(例如,得出測量次數,數據集名,...),不知怎的,不屬於與數據表文件的一部分的所有行:
> buffer <- buffer [nzchar (buffer) > 0L]
> buffer
[1] "0 0 0" "0 0 0"
[3] "54077 184965 81.25" "54266 184776 81.25"
[5] "65130 199986 82.1705426356589" "65513 199600 82.1705426356589"
最後使用read.table
上的修改緩衝區:
> read.table (textConnection (buffer))
V1 V2 V3
1 0 0 0.00000
2 0 0 0.00000
3 54077 184965 81.25000
4 54266 184776 81.25000
5 65130 199986 82.17054
6 65513 199600 82.17054
謝謝!這是工作。 – boyang 2012-04-27 15:03:57