Use transform spec to layout data.

# S3 method for blocks_to_rowrecs_spec
layout_by(transform, table)

Arguments

transform

object of class blocks_to_rowrecs_spec.

table

data.frame or relop.

Value

re-arranged data or data reference (relop).

Examples


d <- wrapr::build_frame(
  "id", "measure", "value" |
  1   , "AUC"    , 0.7     |
  1   , "R2"     , 0.4     |
  2   , "AUC"    , 0.8     |
  2   , "R2"     , 0.5     )

transform <- blocks_to_rowrecs_spec(
  wrapr::qchar_frame(
    "measure", "value" |
    "AUC"    , AUC     |
    "R2"     , R2      ),
  recordKeys = "id")

print(transform)
#> {
#>  block_record <- wrapr::qchar_frame(
#>    "id"  , "measure", "value" |
#>      .   , "AUC"    , AUC     |
#>      .   , "R2"     , R2      )
#>  block_keys <- c('id', 'measure')
#> 
#>  # becomes
#> 
#>  row_record <- wrapr::qchar_frame(
#>    "id"  , "AUC", "R2" |
#>      .   , AUC  , R2   )
#>  row_keys <- c('id')
#> 
#>  # args: c(checkNames = TRUE, checkKeys = TRUE, strict = FALSE, allow_rqdatatable = FALSE)
#> }
#> 

layout_by(transform, d)
#>   id AUC  R2
#> 1  1 0.7 0.4
#> 2  2 0.8 0.5