Hi all,
How can I test for the EOF flag in R? e.g.
f <- file(fname, "rb")
while (???) {
a <- readBin(f, "int", n=1)
}
Thanks.
Hi all,
How can I test for the EOF flag in R? e.g.
f <- file(fname, "rb")
while (???) {
a <- readBin(f, "int", n=1)
}
Thanks.
The readLines function will return a zero-length value when it reaches the EOF.
Try checking the length of data returned by readBin:
while (length(a <- readBin(f, 'int', n=1)) > 0) {
# do something
}