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 file (if you don't want to use another program)?
I'd suggest length(readLines(...)).
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 don't say what OS you are on. If it isn't Windows the easiest thing would be to use wc.
-thomas
______________________________________________ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html