Map field values from one column into new derived columns (query based, takes name of table).

map_fields_q(
  dname,
  cname,
  mname,
  my_db,
  rname,
  ...,
  d_qualifiers = NULL,
  m_qualifiers = NULL
)

Arguments

dname

name of table to re-map.

cname

name of column to re-map.

mname

name of table of data describing the mapping (cname column is source, derived columns are destinations).

my_db

database handle.

rname

name of result table.

...

force later arguments to be by name.

d_qualifiers

optional named ordered vector of strings carrying additional db hierarchy terms, such as schema.

m_qualifiers

optional named ordered vector of strings carrying additional db hierarchy terms, such as schema.

Value

re-mapped table

Examples

if (requireNamespace("DBI", quietly = TRUE) && requireNamespace("RSQLite", quietly = TRUE)) { my_db <- DBI::dbConnect(RSQLite::SQLite(), ":memory:") DBI::dbWriteTable( my_db, 'd', data.frame(what = c("acc", "loss", "val_acc", "val_loss"), score = c(0.8, 1.2, 0.7, 1.7), stringsAsFactors = FALSE), overwrite = TRUE, temporary = TRUE) DBI::dbWriteTable( my_db, 'm', data.frame(what = c("acc", "loss", "val_acc", "val_loss"), measure = c("accuracy", "log-loss", "accuracy", "log-loss"), dataset = c("train", "train", "validation", "validation"), stringsAsFactors = FALSE), overwrite = TRUE, temporary = TRUE) map_fields_q('d', 'what', 'm', my_db, "dm") cdata::qlook(my_db, 'dm') DBI::dbDisconnect(my_db) }
#> table `dm` SQLiteConnection #> nrow: 4 #> 'data.frame': 4 obs. of 4 variables: #> $ what : chr "acc" "loss" "val_acc" "val_loss" #> $ score : num 0.8 1.2 0.7 1.7 #> $ measure: chr "accuracy" "log-loss" "accuracy" "log-loss" #> $ dataset: chr "train" "train" "validation" "validation"