count_lines {genio} | R Documentation |
This function returns the number of lines in a file.
It is intended to result in fast retrieval of numbers of individuals (from FAM or equivalent files) or loci (BIM or equivalent files) when the input files are extremely large and no other information is required from these files.
This code uses C++ to quickly counts lines (like linux's wc -l
but this one is cross-platform).
count_lines(file, ext = NA, verbose = TRUE)
file |
The input file path to read (a string). |
ext |
An optional extension.
If |
verbose |
If |
Note: this function does not work correctly with compressed files (they are not uncompressed prior to counting newlines).
The number of lines in the file.
# count number of individuals from an existing plink *.fam file
file <- system.file("extdata", 'sample.fam', package = "genio", mustWork = TRUE)
n_ind <- count_lines(file)
n_ind
# count number of loci from an existing plink *.bim file
file <- system.file("extdata", 'sample.bim', package = "genio", mustWork = TRUE)
m_loci <- count_lines(file)
m_loci