| extract_array_element | R Documentation |
Helper function to safely extract elements from DuckDB arrays (returned as R lists) with proper error handling.
extract_array_element(array_col, index = NULL, default = NA)
array_col |
A list column from DuckDB array data |
index |
Numeric index (1-based). If NULL, returns full list |
default |
Default value if index is out of bounds |
The array element at the specified index, or full array if index is NULL
library(DBI)
library(duckdb)
con <- rduckhts_connect()
bcf_path <- system.file("extdata", "vcf_file.bcf", package = "Rduckhts")
rduckhts_bcf(con, "variants", bcf_path, overwrite = TRUE)
data <- dbGetQuery(con, "SELECT ALT FROM variants LIMIT 5")
first_alt <- extract_array_element(data$ALT, 1)
all_alts <- extract_array_element(data$ALT)
dbDisconnect(con, shutdown = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.