file.nrow {reader} | R Documentation |
Returns the number of lines in a file, which in the case of a datafile will often correspond to the number of rows, or rows+1. Can also do this for all files in the directory. File equivalent of nrow()
file.nrow(fn = "", dir = "", all.in.dir = FALSE)
fn |
name of the file(s) to get the length of |
dir |
optional path for fn location, or specify all files in dir |
all.in.dir |
select whether to extract length for all files in dir |
returns length of file (or all files)
Nicholas Cooper nick.cooper@cimr.cam.ac.uk
orig.dir <- getwd(); setwd(tempdir()); # move to temporary dir
write.table(matrix(rnorm(100),nrow=10),"temp.txt",col.names=FALSE)
file.nrow("temp.txt")
# use with caution, will be slow if dir contains large files
# not run # file.nrow(all.in.dir=TRUE)
unlink("temp.txt")
setwd(orig.dir) # reset working directory to original