# The array will be 4x4 with dims "rows" and "cols" and domain [1,4]
dom <- tiledb_domain(dims = c(tiledb_dim("rows", c(1L, 4L), 4L, "INT32"),
tiledb_dim("cols", c(1L, 4L), 4L, "INT32")))
# The array will be dense with a single attribute "a" so
# each cell (i,j) cell can store an integer.
schema <- tiledb_array_schema(dom, attrs=c(tiledb_attr("a", type="INT32")))
# Create the (empty) array on disk.
uri <- "quickstart_dense"
tiledb_array_create(uri, schema)
# equivalent to matrix(1:16, 4, 4, byrow=TRUE)
data <- array(c(c(1L, 5L, 9L, 13L),
c(2L, 6L, 10L, 14L),
c(3L, 7L, 11L, 15L),
c(4L, 8L, 12L, 16L)), dim = c(4,4))
# Open the array and write to it.
A <- tiledb_array(uri = uri)
A[] <- data
arr <- tiledb_array(uri); arr[] # list of columns
arr <- tiledb_array(uri, as.data.frame=TRUE); arr[] # a data.frame
arr <- tiledb_array(uri, as.matrix=TRUE); arr[] # a matrix
arr <- tiledb_array(uri, as.array=TRUE); arr[] # an array
library(tiledb) # load our package
uri <- tempfile() # any local directory, more later on cloud access
## any data.frame, data.table, tibble ...; here we use penguins_raw
fromDataFrame(palmerpenguins::penguins_raw, uri)
# we want a data.frame, and we skip the implicit row numbers added as index
x <- tiledb_array(uri, as.data.frame = TRUE, extended = FALSE)
newdf <- x[] # full array (we can index rows and/or cols too)
str(newdf[, 1:14])
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.