A mlr3::DataBackend for vector objects (only package sf is supported).
Super class
mlr3::DataBackend
-> DataBackendVector
Public fields
compact_seq
logical(1)
IfTRUE
, row ids are a natural sequence from 1 tonrow(data)
(determined internally). In this case, row lookup uses faster positional indices instead of equi joins.
Active bindings
rownames
(
integer()
)
Returns vector of all distinct row identifiers, i.e. the contents of the primary key column.colnames
(
character()
)
Returns vector of all column names, including the primary key column.nrow
(
integer(1)
)
Number of rows (observations).ncol
(
integer(1)
)
Number of columns (variables), including the primary key column.geometry
(
integer(1)
)
Returns the sf geometry.
Methods
Inherited methods
Method new()
Creates a backend for spatial vector objects.
Usage
DataBackendVector$new(data, primary_key = NULL)
Arguments
data
(
sf
)
A raster object.primary_key
(
character(1)
|integer()
)
Name of the primary key column, or integer vector of row ids.
Method data()
Returns a slice of the data in the specified format.
Currently, the only supported formats are "data.table"
and "Matrix"
.
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.
Arguments
rows
integer()
Row indices.cols
character()
Column names.data_format
(
character(1)
)
Desired data format, e.g."data.table"
or"Matrix"
.
Method distinct()
Returns a named list of vectors of distinct values for each column
specified. If na_rm
is TRUE
, missing values are removed from the
returned vectors of distinct values. Non-existing rows and columns are
silently ignored.
Arguments
rows
integer()
Row indices.cols
character()
Column names.na_rm
logical(1)
Whether to remove NAs or not.
Returns
Named list()
of distinct values.
Method missings()
Returns the number of missing values per column in the specified slice of data. Non-existing rows and columns are silently ignored.
Arguments
rows
integer()
Row indices.cols
character()
Column names.
Returns
Total of missing values per column (named numeric()
).