R/data_table_exports.R
layout_to_rowrecs_data_table.Rd
Map data records from block records (where each record may be more than one row) to row records (where each record is a single row). Values specified in rowKeyColumns determine which sets of rows build up records and are copied into the result.
layout_to_rowrecs_data_table(
data,
...,
columnToTakeKeysFrom,
columnToTakeValuesFrom,
rowKeyColumns,
sep = "_"
)
data.frame to work with (must be local, for remote please try moveValuesToColumns*
).
force later arguments to bind by name.
character name of column build new column names from.
character name of column to get values from.
character array names columns that should be table keys.
character if not null build more detailed column names.
new data.frame with values moved to columns.
(d2 <- wrapr::build_frame(
"id" , "id2", "measure", "value" |
1 , "a" , "AUC" , 0.7 |
2 , "b" , "AUC" , 0.8 |
1 , "a" , "R2" , 0.4 |
2 , "b" , "R2" , 0.5 ))
#> id id2 measure value
#> 1 1 a AUC 0.7
#> 2 2 b AUC 0.8
#> 3 1 a R2 0.4
#> 4 2 b R2 0.5
(layout_to_rowrecs_data_table(d2,
columnToTakeKeysFrom = "measure",
columnToTakeValuesFrom = "value",
rowKeyColumns = c("id", "id2")))
#> id id2 AUC R2
#> 1 1 a 0.7 0.4
#> 2 2 b 0.8 0.5