Create a general record to record transform specification.
layout_specification(
incoming_shape = NULL,
outgoing_shape = NULL,
...,
recordKeys = character(0),
incoming_controlTableKeys = colnames(incoming_shape)[[1]],
outgoing_controlTableKeys = colnames(outgoing_shape)[[1]],
checkNames = TRUE,
checkKeys = TRUE,
strict = FALSE,
allow_rqdatatable_in = FALSE,
allow_rqdatatable_out = FALSE
)
data.frame, definition of incoming record shape.
data.frame, defintion of outgoing record shape.
not used, force later arguments to bind by name.
vector of columns identifying records.
character, which column names of the incoming control table are considered to be keys.
character, which column names of the outgoing control table are considered to be keys.
passed to rowrecs_to_blocks.
passed to rowrecs_to_blocks.
passed to rowrecs_to_blocks.
logical, if TRUE allow rqdatatable shortcutting on simple conversions.
logical, if TRUE allow rqdatatable shortcutting on simple conversions.
a record specification object
incoming_shape <- qchar_frame(
"row", "col1", "col2", "col3" |
"row1", v11, v12, v13 |
"row2", v21, v22, v23 |
"row3", v31, v32, v33 )
outgoing_shape <- qchar_frame(
"column", "row1", "row2", "row3" |
"col1", v11, v21 , v31 |
"col2", v12, v22 , v32 |
"col3", v13, v23 , v33 )
data <- build_frame(
'record_id', 'row', 'col1', 'col2', 'col3' |
1, 'row1', 1, 2, 3 |
1, 'row2', 4, 5, 6 |
1, 'row3', 7, 8, 9 |
2, 'row1', 11, 12, 13 |
2, 'row2', 14, 15, 16 |
2, 'row3', 17, 18, 19 )
print(data)
#> record_id row col1 col2 col3
#> 1 1 row1 1 2 3
#> 2 1 row2 4 5 6
#> 3 1 row3 7 8 9
#> 4 2 row1 11 12 13
#> 5 2 row2 14 15 16
#> 6 2 row3 17 18 19
layout <- layout_specification(
incoming_shape = incoming_shape,
outgoing_shape = outgoing_shape,
recordKeys = 'record_id')
print(layout)
#> {
#> in_record <- wrapr::qchar_frame(
#> "record_id" , "row" , "col1", "col2", "col3" |
#> . , "row1", v11 , v12 , v13 |
#> . , "row2", v21 , v22 , v23 |
#> . , "row3", v31 , v32 , v33 )
#> in_keys <- c('record_id', 'row')
#>
#> # becomes
#>
#> out_record <- wrapr::qchar_frame(
#> "record_id" , "column", "row1", "row2", "row3" |
#> . , "col1" , v11 , v21 , v31 |
#> . , "col2" , v12 , v22 , v32 |
#> . , "col3" , v13 , v23 , v33 )
#> out_keys <- c('record_id', 'column')
#>
#> # args: c(checkNames = TRUE, checkKeys = TRUE, strict = FALSE, allow_rqdatatable = FALSE)
#> }
#>
data %.>% layout
#> record_id column row1 row2 row3
#> 1 1 col1 1 4 7
#> 2 1 col2 2 5 8
#> 3 1 col3 3 6 9
#> 4 2 col1 11 14 17
#> 5 2 col2 12 15 18
#> 6 2 col3 13 16 19
data %.>% layout %.>% .(t(layout))
#> record_id row col1 col2 col3
#> 1 1 row1 1 2 3
#> 2 1 row2 4 5 6
#> 3 1 row3 7 8 9
#> 4 2 row1 11 12 13
#> 5 2 row2 14 15 16
#> 6 2 row3 17 18 19