R/data_table_exports.R
layout_to_blocks_data_table.Rd
Map a data records from row records (records that are exactly single rows) to block records (records that may be more than one row). All columns not named in columnsToTakeFrom are copied to each record row in the result.
layout_to_blocks_data_table( data, ..., nameForNewKeyColumn, nameForNewValueColumn, columnsToTakeFrom, columnsToCopy = setdiff(colnames(data), columnsToTakeFrom) )
data | data.frame to work with. |
---|---|
... | force later arguments to bind by name. |
nameForNewKeyColumn | character name of column to write new keys in. |
nameForNewValueColumn | character name of column to write new values in. |
columnsToTakeFrom | character array names of columns to take values from. |
columnsToCopy | character array names of columns to copy. |
new data.frame with values moved to rows.
#> id id2 AUC R2 #> 1 1 a 0.7 0.4 #> 2 2 b 0.8 0.5(layout_to_blocks_data_table( d, nameForNewKeyColumn = "measure", nameForNewValueColumn = "value", columnsToTakeFrom = c("AUC", "R2"), columnsToCopy = c("id", "id2")))#> 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