layout_to_rowrecs_data_table: Map data records from block records that have one row per...

Description Usage Arguments Value Examples

View source: R/data_table_exports.R

Description

Map data records from block records (where each record may be more than one row) to row records (where each record is a single row). Values specified in rowKeyColumns determine which sets of rows build up records and are copied into the result.

Usage

1
2
3
4
5
6
7
8
layout_to_rowrecs_data_table(
  data,
  ...,
  columnToTakeKeysFrom,
  columnToTakeValuesFrom,
  rowKeyColumns,
  sep = "_"
)

Arguments

data

data.frame to work with (must be local, for remote please try moveValuesToColumns*).

...

force later arguments to bind by name.

columnToTakeKeysFrom

character name of column build new column names from.

columnToTakeValuesFrom

character name of column to get values from.

rowKeyColumns

character array names columns that should be table keys.

sep

character if not null build more detailed column names.

Value

new data.frame with values moved to columns.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
(d2 <- wrapr::build_frame(
  "id"  , "id2", "measure", "value" |
    1   , "a"  , "AUC"    , 0.7     |
    2   , "b"  , "AUC"    , 0.8     |
    1   , "a"  , "R2"     , 0.4     |
    2   , "b"  , "R2"     , 0.5     ))

(layout_to_rowrecs_data_table(d2,
                             columnToTakeKeysFrom = "measure",
                             columnToTakeValuesFrom = "value",
                             rowKeyColumns = c("id", "id2")))

rqdatatable documentation built on Jan. 23, 2022, 1:06 a.m.