Learn R Programming

R.utils (version 2.12.3)

readTableIndex: Reads a single column from file in table format

Description

Reads a single column from file in table format, which can then be used as a index-to-row (look-up) map for fast access to a subset of rows using readTable().

Usage

# S3 method for default
readTableIndex(..., indexColumn=1, colClass="character", verbose=FALSE)

Value

Returns a vector.

Arguments

indexColumn

An single integer of the index column.

colClass

A single character specifying the class of the index column.

...

Arguments passed to readTable() used internally.

verbose

A logical or a Verbose object.

Author

Henrik Bengtsson

See Also

readTable().

Examples

Run this code
if (FALSE) {
   # File containing data table to be access many times
   filename <- "somefile.txt"

   # Create a look-up index
   index <- readTableIndex(filename)

   # Keys of interest
   keys <- c("foo", "bar", "wah")

   # Read only those keys and do it fast
   df <- readTable(filename, rows=match(keys, index))
}

Run the code above in your browser using DataLab