Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

countLines

Count lines in all (text) files in a directory whose file name matches a pattern


Description

countLines visits all files in a directory path dirPath whose base (i.e., file) name matches pattern. Lines in the file are counted as the number of new line characters.

Usage

countLines(dirPath, pattern=character(0), ..., useFullName=FALSE)

Arguments

dirPath

A character vector (or other object; see methods defined on this generic) giving the directory path (relative or absolute) of files whose lines are to be counted.

pattern

The (grep-style) pattern describing files whose lines are to be counted. The default (character(0)) results in line counts for all files in the directory.

...

Additional arguments, passed internally to list.files. See list.files.

useFullName

A logical(1) indicating whether elements of the returned vector should be named with the base (file) name (default; useFullName=FALSE) or the full path name (useFullName=TRUE).

Value

A named integer vector of line counts. Names are paths to the files whose lines have been counted, excluding dirPath.

Author(s)

Martin Morgan

Examples

sp <- SolexaPath(system.file('extdata', package='ShortRead'))
countLines(analysisPath(sp))
countLines(experimentPath(sp), recursive=TRUE)
countLines(experimentPath(sp), recursive=TRUE, useFullName=TRUE)

ShortRead

FASTQ input and manipulation

v1.48.0
Artistic-2.0
Authors
Martin Morgan, Michael Lawrence, Simon Anders
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.