Create a record specification object that holds the pivot control table, spefication of extra row keys, and control table keys.
new_record_spec(controlTable, ..., recordKeys = character(0), controlTableKeys = colnames(controlTable)[[1]])
controlTable | an all character data frame or cdata pivot control. |
---|---|
... | not used, force later arguments to bind by name. |
recordKeys | vector of columns identifying records. |
controlTableKeys | vector of keying columns of the controlTable. |
a record specification object
d <- wrapr::build_frame( "id", "measure", "value" | 1 , "AUC" , 0.7 | 1 , "R2" , 0.4 | 2 , "AUC" , 0.8 | 2 , "R2" , 0.5 ) record_spec <- new_record_spec( wrapr::qchar_frame( measure, value | AUC , "AUC" | R2 , "R2" ), recordKeys = "id") (d2 <- record_spec %pivot% d)#> id AUC R2 #> 1 1 0.7 0.4 #> 2 2 0.8 0.5# identity ( record_spec %pivot% d ) %pivot% record_spec#> id measure value #> 1 1 AUC 0.7 #> 2 1 R2 0.4 #> 3 2 AUC 0.8 #> 4 2 R2 0.5# identity record_spec %pivot% d %pivot% record_spec#> id measure value #> 1 1 AUC 0.7 #> 2 1 R2 0.4 #> 3 2 AUC 0.8 #> 4 2 R2 0.5# identity record_spec %pivot% ( d2 %pivot% record_spec )#> id AUC R2 #> 1 1 0.7 0.4 #> 2 2 0.8 0.5