Stack Columns

DESCRIPTION:

Combine or stack separate columns of a data set into a single column, replicating values in other columns as necessary.

This function requires the bigdata library section to be loaded.

USAGE:

bd.stack(data, columns,
          replicate=character(0),
          stack.column.name="STACK.value",
          group.column.name=NULL)

REQUIRED ARGUMENTS:

data
input data set, a bdFrame or data.frame.
columns
names or numbers of columns to be stacked.

OPTIONAL ARGUMENTS:

replicate
names or numbers of columns to be replicated.
stack.column.name
name of new stacked column.
group.column.name
if non- NULL, name of an additional group column to be created in the output data set. In each output row, the group column contains the name of the original column that contained the data value in the new stacked column.

VALUE:

A bdFrame or data.frame, of the same type as x.

DETAILS:

This function combines the stack columns into a single column; the values of the replicate columns are replicated in parallel. Each row in the output data contains a stacked value and the corresponding values of the replicated columns. All columns to be stacked must be of the same type.

SEE ALSO:

EXAMPLES:

## Stack numeric columns "Mileage" and "Fuel",
## keeping the "Type" column, and adding a
## group column
bd.stack(fuel.frame[1:5,], c("Mileage", "Fuel"),
          replicate="Type",
          group.column.name="STACK.var")