DFI.subset {bsearchtools}R Documentation

Subset a DFI object

Description

Function to subset a DFI object efficiently (using binary search) by creating complex filters on indexed columns. For details about column indexes, refer to DFI, for information about NA handling, refer to rowfilters.DFI.

Usage

DFI.subset(DFIobj, filter=NULL, return.indexes=FALSE, 
           sort.indexes=TRUE, colFilter=NULL, drop=NULL)

Arguments

DFIobj

a DFI object.

filter

a filter object created by functions EQ,RG,IN,AND,OR,NOT.

return.indexes

if TRUE, the row indexes satisfying the filter are returned instead of the DFI subset.

sort.indexes

if FALSE the order of the rows or row.index returned will not be necessarily equal to the original order in the DFI object. If TRUE, subsetting will keep the original row/row.indexes order. FALSE usually gives a better performance.

colFilter

if return.indexes==TRUE is ignored; otherwise, if not NULL, it will be passed as second argument of data.frame/matrix subset operator i.e. [,colFilter]

drop

if different from NULL is passed as drop argument of data.frame and matrix subset (ignored if return.indexes=TRUE).

Value

A subset of the data.frame or matrix wrapped by the DFI object, unless return.indexes==TRUE in which case an integer vector with the row indexes will be returned.

See Also

DFI, EQ, IN, RG, NOT, AND, OR

Examples


### create a simple DFIobj
DF <- data.frame(Foo=c(3,5,7,1,5,8,7,10),
                 Bar=c("A","B","B","C","B","B","C","A"),
                 Baz=c(TRUE,FALSE),
                 stringsAsFactors=FALSE)
DFIobj <- DFI(DF, c("Foo","Bar")) # create a DFI from DF with indexes on "Foo" and "Bar" columns

DFI.subset(DFIobj, filter=OR(EQ('Foo',5),EQ('Bar','B')))


[Package bsearchtools version 0.0.61 Index]