| 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 |
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 |
drop |
if different from |
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
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')))