[R] Value Lookup from File without Slurping

Wacek Kusnierczyk Waclaw.Marcin.Kusnierczyk at idi.ntnu.no
Fri Jan 16 12:30:00 CET 2009


r at quantide.com wrote:
>
> Using file() is not a real reading of all the file. This function will
> simply open a connection to the file without reading it.
> countLines should do something lile "wc -l" from a bash shell


just for a test:

cat(rep('', 10^7), file='test.txt', fill=1)
library(R.utils)
system.time(countLines('test.txt'))

... and the file is just about 30MB (and it makes no real difference if
it is stuffed with newlines or not).

vQ




More information about the R-help mailing list