This is a simple R package to quickly read a random sample of lines of a flat text file (such as a csv) into R. This allows you to get a subsample into R without having to read the (possibly large) file into memory first.

If you would like to contribute to this project, please see the file. Idea inspired by Eduardo Arino de la Rubia's fast_sample.


From CRAN:


The development version is maintained on GitHub, and can easily be installed by any of the packages that offer installations from GitHub:

### Pick your preference

Package Use

ret <- sample_csv(file, p=.001)

There is also a sample_lines() function for reading in (line) subsamples of unstructured text akin to readLines(). See package vignette for more details.

For more information, including benchmarks and implementation details, please see the package vignette:

vignette("lineSampler", package="lineSampler")

Code Re-Use

The C code in the src/lineSampler tree of this package can easily be re-purposed for use outside of R with some minor modifications. The components that need to be edited can be found in the file:

Detailed explanations are contained there, but you will need:

wrathematics/lineSampler documentation built on May 13, 2018, 11:19 a.m.