fastReadLines: Fast readLines.

Description Usage Arguments Value Examples

View source: R/my_functions.r

Description

Replacement for readLines, faster.

Usage

1
fastReadLines(fname, newlinechar = "\n", nchars = NULL)

Arguments

fname

Filename to read.

newlinechar

The new line character in the file.

Value

A vector containing all the lines in the file.

Examples

1
2
3
4
5
6
7
8
9
library(microbenchmark)
writeLines(replicate(100000, sample(letters, size=100, replace=T)), con="/tmp/temp.txt")
microbenchmark(fastReadLines("/tmp/temp.txt"), 
               readLines("/tmp/temp.txt"), times=3)[,c("expr", "mean"), drop=F]

Unit: milliseconds
                          expr      min       lq     mean   median       uq
fastReadLines("/tmp/temp.txt") 335.3874 335.9188 336.5900 336.4502 337.1912
    readLines("/tmp/temp.txt") 724.9136 725.4523 727.2444 725.9911 728.4098

traversc/trqwe documentation built on Dec. 4, 2020, 4:21 a.m.