View source: R/data_table_exports.R
layout_to_blocks_data_table | R Documentation |
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.
(d <- wrapr::build_frame(
"id" , "id2", "AUC", "R2" |
1 , "a" , 0.7 , 0.4 |
2 , "b" , 0.8 , 0.5 ))
(layout_to_blocks_data_table(
d,
nameForNewKeyColumn = "measure",
nameForNewValueColumn = "value",
columnsToTakeFrom = c("AUC", "R2"),
columnsToCopy = c("id", "id2")))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.