This is the abstract base class for data backends.
Data Backends provide a layer of abstraction for various data storage systems. It is not recommended to work directly with the DataBackend. Instead, all data access is handled transparently via the Task.
To connect to out-of-memory database management systems such as SQL servers, see mlr3db.
The required set of fields and methods to implement a custom DataBackend is listed in the respective sections. See DataBackendDataTable or DataBackendMatrix for exemplary implementations of the interface.
Note: This object is typically constructed via a derived classes, e.g. DataBackendDataTable or DataBackendMatrix,
or via the S3 method
The format of the input data depends on the specialization. E.g., DataBackendDataTable expects a
data.table::data.table() and DataBackendMatrix expects a
constructed with the Matrix package.
Each DataBackend needs a way to address rows, which is done via a column of unique values, referenced here by
The use of this variable may differ between backends.
Set of supported formats, e.g.
Number of rows (observations).
Number of columns (variables), including the primary key column.
Returns vector of all column names, including the primary key column.
rownames :: (
Returns vector of all distinct row identifiers, i.e. the primary key column.
Returns a unique hash for this backend. This hash is cached.
Vector of supported data formats. A specific format can be chosen in the
data(rows = NULL, cols = NULL, format = "data.table")
Returns a slice of the data in the specified format. Currently, the only supported formats are
The rows must be addressed as vector of primary key values, columns must be referred to via column names.
Queries for rows with no matching row id and queries for columns with no matching column name are silently ignored.
Rows are guaranteed to be returned in the same order as
rows, columns may be returned in an arbitrary order.
Duplicated row ids result in duplicated rows, duplicated column names lead to an exception.
distinct(rows, cols, na_rm = TRUE)
logical(1)) -> named
Returns a named list of vectors of distinct values for each column specified. If
TRUE, missing values are removed from the returned vectors of distinct values.
Non-existing rows and columns are silently ignored.
NULL, all possible distinct values will be returned, even if the value is not present in the data.
This affects factor-like variables with empty levels, if supported by the backend.
head(n = 6)
Returns the first up-to
n rows of the data as
character()) -> named
Returns the number of missing values per column in the specified slice of data. Non-existing rows and columns are silently ignored.
Extension Packages: mlr3db
1 2 3 4 5 6 7 8
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.