On Mon, 2004-12-06 at 22:12 +0800, Hu Chen wrote:
hi all
If I wanna get the total number of lines in a big file without reading
the file's content into R as matrix or data frame, any methods or
functions?
thanks in advance.
Regards
See ?readLines
You can use:
length(readLines(FileName))
Hu Chen wrote:
hi all
If I wanna get the total number of lines in a big file without reading
the file's content into R as matrix or data frame, any methods or
functions?
You must read it in R, or how do you think should one determine the
number of lines in a file (if you don't want to use another
From: Marc Schwartz
On Mon, 2004-12-06 at 22:12 +0800, Hu Chen wrote:
hi all
If I wanna get the total number of lines in a big file
without reading
the file's content into R as matrix or data frame, any methods or
functions?
thanks in advance.
Regards
See ?readLines
You can
On Mon, 6 Dec 2004, Uwe Ligges wrote:
Hu Chen wrote:
hi all
If I wanna get the total number of lines in a big file without reading
the file's content into R as matrix or data frame, any methods or
functions?
You must read it in R, or how do you think should one determine the number of
lines in a
From: Liaw, Andy
From: Marc Schwartz
On Mon, 2004-12-06 at 22:12 +0800, Hu Chen wrote:
hi all
If I wanna get the total number of lines in a big file
without reading
the file's content into R as matrix or data frame, any methods or
functions?
thanks in advance.
On Mon, 2004-12-06 at 12:26 -0500, Liaw, Andy wrote:
Marc alerted me off-list that count.fields() might spent time delimiting
fields, which is not needed for the purpose of counting lines, and suggested
using sep=\n as a possible way to make it more efficient. (Thanks, Marc!)
Here are
Thomas Lumley [EMAIL PROTECTED] writes:
[...]
If the file is large enough that you don't want to read the whole
thing at once you can read it in chunks using readLines(). If all the
lines are the same length you can find the size of the file and divide
by the length of a line.
Also, you
David Whiting wrote:
Thomas Lumley [EMAIL PROTECTED] writes:
[...]
If the file is large enough that you don't want to read the whole
thing at once you can read it in chunks using readLines(). If all the
lines are the same length you can find the size of the file and divide
by the length of a
From: Marc Schwartz
On Mon, 2004-12-06 at 12:26 -0500, Liaw, Andy wrote:
Marc alerted me off-list that count.fields() might spent
time delimiting
fields, which is not needed for the purpose of counting
lines, and suggested
using sep=\n as a possible way to make it more efficient.
Liaw, Andy wrote:
From: Marc Schwartz
On Mon, 2004-12-06 at 22:12 +0800, Hu Chen wrote:
hi all
If I wanna get the total number of lines in a big file
without reading
the file's content into R as matrix or data frame, any methods or
functions?
thanks in advance.
Regards
See
On Mon, 2004-12-06 at 14:00 -0500, Liaw, Andy wrote:
Marc,
I wrote the following function to read the file in chunks:
countLines - function(file, chunk=1e3) {
f - file(file, r)
on.exit(close(f))
nLines - 0
while((n - length(readLines(f, chunk))) 0) nLines - nLines + n
Hu Chen asked
If I wanna get the total number of lines in a big file without reading
the file's content into R as matrix or data frame, any methods or
functions?
_Something_ must read it, but it doesn't have to be R.
On a UNIX system, you can simply do
12 matches
Mail list logo