data.frame
).R/map_fields.R
map_fields.Rd
Map field values from one column into new derived columns (takes a data.frame
).
map_fields(d, cname, m)
d | name of table to re-map. |
---|---|
cname | name of column to re-map. |
m | name of table of data describing the mapping (cname column is source, derived columns are destinations). |
re-mapped table
d <- data.frame(what = c("acc", "loss", "val_acc", "val_loss"), score = c(0.8, 1.2, 0.7, 1.7), stringsAsFactors = FALSE) 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) map_fields(d, 'what', m)#> what score measure dataset #> 1 acc 0.8 accuracy train #> 2 loss 1.2 log-loss train #> 3 val_acc 0.7 accuracy validation #> 4 val_loss 1.7 log-loss validation