file.nrow: Find the number of rows (lines) in a file.

Description Usage Arguments Value Author(s) See Also Examples

View source: R/reader.R

Description

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()

Usage

1
file.nrow(fn = "", dir = "", all.in.dir = FALSE)

Arguments

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

Value

returns length of file (or all files)

Author(s)

Nicholas Cooper nick.cooper@cimr.cam.ac.uk

See Also

file.ncol

Examples

1
2
3
4
5
6
7
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

reader documentation built on May 2, 2019, 9:27 a.m.