merged.stack: Take a List of Stacked data.tables and Merge Them

Description Usage Arguments Value Note Author(s) See Also Examples

Description

A wrapper around the Stacked function to merge the resulting list into a single data.table.

Usage

1
2
merged.stack(data, id.vars = NULL, var.stubs, sep, keep.all = TRUE,
  ...)

Arguments

data

The input data.frame.

id.vars

The columns to be used as "ID" variables. Defaults to NULL, at which point, all names which are not identified as variable groups are used as the identifiers.

var.stubs

The prefixes of the variable groups.

sep

The character that separates the "variable name" from the "times" in the source data.frame. Alternatively, can be set to "var.stubs" (in quotes) if you do not have a value for sep.

keep.all

Logical. Should all the variables in the source data.frame be kept (keep.all = TRUE) or only those which comprise the id.vars and split data from the var.stubs (keep.all = FALSE).

...

Other arguments to be passed on to Stacked (for example, keep.rownames to retain the rownames of the input dataset, or atStart, in case sep = "var.stubs" is specified).

Value

A merged data.table.

Note

The keyed argument to Stacked has been hard- coded to TRUE to make merge work.

Author(s)

Ananda Mahto

See Also

Stacked, Reshape

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
set.seed(1)
mydf <- data.frame(id_1 = 1:6, id_2 = c("A", "B"),
                   varA.1 = sample(letters, 6),
                   varA.2 = sample(letters, 6),
                   varA.3 = sample(letters, 6),
                   varB.2 = sample(10, 6),
                   varB.3 = sample(10, 6),
                   varC.3 = rnorm(6))
mydf
merged.stack(mydf, var.stubs = c("varA", "varB", "varC"), sep = ".")

splitstackshape documentation built on May 1, 2019, 8:20 p.m.