DFI {bsearchtools} | R Documentation |
Turn a data.frame (or matrix) object into a DFI object allowing faster lookups on indexed columns (indexed column to be intended as DB indexes).
DFI(DF, indexes.col.names=colnames(DF))
as.DFI(DF, indexes.col.names=colnames(DF)) # exactly the same as DFI()
is.DFI(x)
## S3 method for class 'DFI'
print(x, ...)
DF |
A data.frame or matrix object (must have column names defined). |
indexes.col.names |
The column names for which we want to create the indexes. Only integer,numeric,logical and character are supported, so be careful since data.frame by default turns strings into factors (see data.frame |
x |
A DFI object. |
... |
optional arguments passed to inner |
Basically, DFI()
function creates a wrapper of DF
.
This wrapper contains the original data.frame or matrix plus the necessary indexes data and the class of the wrapped object.
These extra data will be used to perform faster lookups (in DFI.subset
function) and can be extracted using the appropriate functions
DFI.unWrap
,
DFI.indexes
,
DFI.getIndex
.
An object with class "DFI"
Since version 0.0.47 DFI objects do not inherit from data.frame or matrix anymore, hence they cannot be modified/subsetted using data.frame/matrix standard operators.
This has been changed since the column indexes are not recreated automatically and once the object is modified, DFI.subset could give wrong results without any warning.
To use the standard replacement and subset operators, extract the original object first using DFI.unWrap(DFIobj)
.
DFI.subset
DFI.unWrap
DFI.indexes
DFI.getIndex
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