[R] Fast way to determine number of lines in a file
hadley wickham
h.wickham at gmail.com
Tue Feb 9 15:47:03 CET 2010
> I was looking for a fast line counter as well a while ago and ended up
> writing a small function in R:
>
> countLines() in the R.utils package
>
> At least at the time, it was faster than readLines() [for unknown
> reasons]. It is also more memory efficient. It supports connections.
> I don't think it beats a system call to 'wc', though. When there
> will be a faster solution available, it'll be calling that instead.
> It does not avoid reading the file twice.
Perfect - exactly what I was looking for.
Thanks!
Hadley
--
http://had.co.nz/
More information about the R-help
mailing list