[R] How to read last (incomplete) line from gzfile()?
S.J.Eglen at damtp.cam.ac.uk
Sun Apr 20 19:35:07 CEST 2008
I have some text files that do not have trailing \n on the last
(incomplete) line; how do I read in the last line?
e.g. here is a test case: [linux + R version 2.6.1 (2007-11-26) ]
z <- gzfile("short.gz", open="w")
z <- gzfile('short.gz')
 "7" "5"
readLines would indicate that for blocking connections (which I assume
this is), the last line (containing 3) would be read in, and a warning
would be generated. I get the desired behaviour if I use a file() on
a file that is not compressed:
y <- file("short", open="w")
y <- file('short')
 "7" "5" "3"
In readLines(y) : incomplete final line found on 'short'
What am I missing?
More information about the R-help