Add Column(s) to a Dataset

DESCRIPTION:

Assigns a column (or columns) to a 1- or 2-dimensional dataset.

USAGE:

assign.cols(target, columns, value, column.names=NULL) 

REQUIRED ARGUMENTS:

target
1- or 2-dimensional dataset to which the column(s) will be assigned. A 1-dimensional dataset is considered to be a single, unnamed column.
columns
logical, integer, or character vector specifying the column(s) of target which is/are to be assigned. Ignored if target is a 1-dimensional dataset.
value
value to be assigned to columns of target (assumed to be of an appropriate data type). If target is a 1-dimensional dataset, value must be a single column and the result will have count.rows(value) rows and name.rows(value) row names.

OPTIONAL ARGUMENTS:

column.names
character vector specifying the name(s) of the assigned column(s). Ignored if target is a 1-dimensional dataset. The default value is name.cols(value).

VALUE:

The target dataset with the assigned column(s).

SEE ALSO:

, , , , , , .

EXAMPLES:

new.cols <- count.cols(fuel.frame)-1:0 
fuel.new <- assign.cols(fuel.frame.orig, count.cols(fuel.frame.orig)+1:2, 
                        select.cols(fuel.frame, new.cols), 
                        paste("new", name.cols(fuel.frame)[new.cols], sep="."))