Unstack a Column

DESCRIPTION:

Separate a data set column into a number of columns.

This function requires the bigdata library section to be loaded.

USAGE:

bd.unstack(data, value.column,
            group.columns=character(0),
            key.columns=character(0),
            names. = NULL,
            drop.empty.columns=T,
            sort=T)

REQUIRED ARGUMENTS:

data
input data set: a bdFrame or data.frame.
value.column
name or number of column to be separated into multiple columns.

OPTIONAL ARGUMENTS:

group.columns
names or numbers of one or more group columns, which must be categorical. These will be the basis for creating the new "unstacked" columns. For example, if you select a column with three levels (A, B, and C), this function will create three new columns (labeled A, B, and C). If you select two columns and one has levels X, Y and Z and the other has levels A and B, this function will create six new columns labeled X_A, X_B, Y_A, Y_B, Z_A and Z_B. If there are any missing values in a selected group column, the missing data will be treated as another level (labeled NaN).
key.columns
names or numbers of zero or more key columns. These columns are used to establish uniqueness or row position for similar values in the columns group.columns. Any combination of key column values that are not unique will lead to loss of data, as the last non-unique value will be used.
names.
names for new columns.
drop.empty.columns
if TRUE, prune empty columns from the output. If group.columns specifies multiple columns, this function uses the cross-product of the group.columns factor levels. This can lead to category combinations that do not actually exist in the data. The prune.empty.columns argument determines whether to remove these unused columns from the output.
sort
if FALSE, do not sort the input data by c(key.columns,group.columns) first.

VALUE:

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

DETAILS:

SEE ALSO:

EXAMPLES:

# Unstack fuel.frame "Weight" according to "Type" (use mean if there
# are more than one occurence of each "Type").
bd.unstack(bd.aggregate(fuel.frame, "Weight", "Type",  "mean", "Weight"), "Weight", "Type")