bselect {bread}R Documentation

Pre-selects columns of a data file before loading it in memory

Description

Simple wrapper for data.table::fread() allowing to select columns of data from a file with the Unix 'cut' command. This method is useful if you want to load a file too large for your available memory (and encounter the 'cannot allocate vector of size' error).

Usage

bselect(file = NULL, colnames = NULL, colnums = NULL, ...)

Arguments

file

String. Full path to a file

colnames

Vector of strings. Exact names of columns to select. If both colnames and colnums are provided, colnums will be prefered.

colnums

Vector of numeric. Columns index numbers.

...

Arguments that must be passed to data.table::fread() like 'sep' or 'dec'.

Value

A dataframe with the selected columns

Examples

file <- system.file('extdata', 'test.csv', package = 'bread')
## Select the columns numbered 1 and 3
bselect(file = file, colnums = c(1,3))
## Select the columns named 'PRICE' and 'COLOR'
bselect(file = file, colnames = c('PRICE', 'COLOR'))

[Package bread version 0.4.1 Index]