layout_to_blocks_data_table: Map a data records from row records to block records with one...

Description Usage Arguments Value Examples

View source: R/data_table_exports.R

Description

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.

Usage

1
2
3
4
5
6
7
8
layout_to_blocks_data_table(
  data,
  ...,
  nameForNewKeyColumn,
  nameForNewValueColumn,
  columnsToTakeFrom,
  columnsToCopy = setdiff(colnames(data), columnsToTakeFrom)
)

Arguments

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.

Value

new data.frame with values moved to rows.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
(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")))

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