Cross product vectors in database.
expand_grid( db, values, ..., temporary = TRUE, table_name = (wrapr::mk_tmp_name_source("eg"))(), qualifiers = NULL )
db | database handle |
---|---|
values | named list of value vectors. |
... | force later arguments to bind by name. |
temporary | logical if TRUE try to make temporary table. |
table_name | name to land result as. |
qualifiers | optional named ordered vector of strings carrying additional db hierarchy terms, such as schema. |
table handle.
if (requireNamespace("DBI", quietly = TRUE) && requireNamespace("RSQLite", quietly = TRUE)) { my_db <- DBI::dbConnect(RSQLite::SQLite(), ":memory:") values <- list(nums = 1:3, lets = c("a", "b")) res <- expand_grid(my_db, values) print(res) execute(my_db, res) DBI::dbDisconnect(my_db) }#> [1] "mk_td(\"eg_54354041219460590616_0000000000\", c( \"nums\", \"lets\"))" #> nums lets #> 1 1 a #> 2 1 b #> 3 2 a #> 4 2 b #> 5 3 a #> 6 3 b #> ...