dt_keybin_reshape: Long to wide key-value reshaping

View source: R/dt_ops.R

dt_keybin_reshapeR Documentation

Long to wide key-value reshaping

Description

Reshape a long format data.table using key-value pairs with data.table::dcast

Usage

dt_keybin_reshape(
  x,
  id_name,
  key_name,
  positive = 1,
  negative = 0,
  xname = NULL,
  verbose = TRUE
)

Arguments

x

A data.table object

id_name

Character: Name of column in x that defines the IDs identifying individual rows

key_name

Character: Name of column in x that holds the key

positive

Numeric or Character: Used to fill id ~ key combination present in the long format input x

negative

Numeric or Character: Used to fill id ~ key combination NOT present in the long format input x

xname

Character: Name of x to be used in messages

verbose

Logical: If TRUE, print messages to the console

Author(s)

E.D. Gennatas

Examples

## Not run: 
x <- data.table(
  ID = rep(1:3, each = 2),
  Dx = c("A", "C", "B", "C", "D", "A")
)
dt_keybin_reshape(x, id_name = "ID", key_name = "Dx")

## End(Not run)

egenn/rtemis documentation built on Nov. 22, 2024, 4:12 a.m.