requireNamespace("Matrix")
data = Matrix::Matrix(sample(0:1, 20, replace = TRUE), ncol = 2)
colnames(data) = c("x1", "x2")
dense = data.frame(
..row_id = 1:10,
num = runif(10),
fact = factor(sample(c("a", "b"), 10, replace = TRUE), levels = c("a", "b"))
)
b = as_data_backend(data, dense = dense, primary_key = "..row_id")
b$head()
b$data(1:3, b$colnames, data_format = "Matrix")
b$data(1:3, b$colnames, data_format = "data.table")
Run the code above in your browser using DataLab