INSERTCOL

Purpose:

Inserts a column in a table.

Syntax:

INSERTCOL(series, newcol, colnum)

series

-

A series or table.

newcol

-

A series, the new column to insert.

colnum

-

Optional. An integer, the column number insertion location:

If colnum < 0, the new column is inserted before the first column.

If colnum >= numcols, the new column is appended after the last column. Defaults to numcols, append new column to table.

Returns:

A series or table.

Example:

W1: reshape(1..10, {3, 5, 2})

W2: insertcol(W1, 1..3)

W3: insertcol(W1, 1..3, 2)

W4: insertcol(W1, 1..3, 3)

 

W1 contains the table:

 

1   4   9

2   5  10

3   6

    7

    8

 

W2 contains the table:

 

1   4   9   1

2   5  10   2

3   6       3

    7

    8

 

W3 contains the table:

 

1   4   1   9

2   5   2  10

3   6   3

    7

    8

 

W4 contains the table:

 

1   4   9   1

2   5   10  2

3   6       3

    7

    8

Example:

W1: reshape(1..10, {3, 5, 2})

W2: insertcol(W1, ones(2, 2), 1)

 

W1 contains the table:

 

1   4   9

2   5  10

3   6

    7

    8

 

W2 contains the table:

 

1   1   1   4   9

2   1   1   5  10

3           6    

            7

            8

Remarks:

INSERTCOL does not operate in-place, a new series is returned.

 

As shown in the second example, if the new series contains multiple columns, all columns are inserted.

 

See REPLACECOL to replace an existing column with new values.

See Also:

COLEXTRACT

DELETE

DELETECOL

DELETEROW

INSERT

REPLACE

REPLACECOL

RESHAPE

REMOVE