Move Column(s) from a Dataset to Another Dataset

DESCRIPTION:

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

USAGE:

move.col(target, target.start.col, source=<<see below>>, 
         source.col.spec=<<see below>>, overwrite=F) 

REQUIRED ARGUMENTS:

target
1- or 2-dimensional dataset to which the column(s) will be moved. A 1-dimensional dataset is considered to be a single, unnamed column.
target.start.col
integer or character (name-matching) value specifying the column of target to which the move is to be done. For 2-dimensional datasets, to specify the last column of target plus one, use "@END", "", or a character value not matching any of the column names of target; in the latter case, target.start.col will be used for the name(s) of the moved column(s).

OPTIONAL ARGUMENTS:

source
2-dimensional dataset from which the column(s) will be moved. The default is target.
source.col.spec
logical, integer, or character (name-matching) vector specifying the column(s) of source which is/are to be moved. To specify all columns of source, use "@ALL" or ""; to specify the last column of source, use "@END" or "". The default is "@ALL". Only one column may be specified if target is a 1-dimensional dataset.
overwrite
logical flag: if TRUE, the existing column(s) of target will be overwritten by the moved column(s); if FALSE, all existing columns of target (if any) from target.start.col to the last column will be shifted by the number of columns as determined by source.col.spec. overwrite must be TRUE if target is a 1-dimensional dataset.

VALUE:

The target dataset with the moved column(s). For 2-dimensional datasets, the name(s) of the moved column(s) will be the name(s) of the source.col.spec column(s) of source, unless overridden by target.start.col.

SIDE EFFECTS:

The source dataset will have its source.col.spec column(s) removed. It must therefore be a 2-dimensional dataset.

SEE ALSO:

, , , , , .

EXAMPLES:

# remember the original "@END" column of prim4 
prim4.last <- count.cols(prim4) 
# swap ending columns of prim4 and prim9 
prim4 <- move.col(prim4, "@END", prim9, "@END") 
prim9 <- move.col(prim9, "@END", prim4, prim4.last)