# RESHAPE

## Purpose:

Creates a table of values by splitting a specified series into specified lengths.

## Syntax:

RESHAPE(series, lengths, start, overlap, zeroflag)

 series - A series or table. lengths - A series of lengths. start - Optional. An integer indicating start index. Defaults to 1. overlap - Optional. An integer indicating segment overlap. Defaults to 0. zeroflag - Optional. An integer. Allow zero length segments. Defaults to 0, no zero length segments.

A table.

## Example:

W1: 1..10

W2: reshape(W1, {2, 4, 3})

W2 contains the table

1 3 7 10

2 4 8

5 9

6

by dividing W1 into four segments of length 2, 4, 3 and length(W1)-(2+4+3) = 1 values.

## Example:

W1: 1..10

W2: reshape(W1, {3, 1, 4})

returns the table:

1 4 5 9

2   6 10

3   7

8

## Example:

W1: 1..10

W2: reshape(W1, {3, 0, 4})

returns the table:

1 4 8

2 5 9

3 6 10

7

The 0 length column is removed.

## Example:

W1: 1..10

W2: reshape(W1, {3, 0, 4}, 1, 0, 1)

returns the table:

1 0 4 8

2   5 9

3   6 10

7

The zero length column is preserved with a value of 0.

## Example:

W1: 1..10

W2: reshape(W1, {3, 0, 4}, 1, 0, -1)

returns the table:

1 5 9

2 6 10

3 7

8

The zero length column is removed along with the data point corresponding to the zero length column.

## Remarks:

RESHAPE creates a table of values by splitting series into multiple columns where the length of each column is specified by the lengths series. Any remaining values are placed in the final column.

If zeroflag == 0 (the default), zero length columns are skipped.

If zeroflag > 0, zero length columns are preserved with the value 0.

If zeroflag < 0, zero length columns are skipped as well as the corresponding data point for that column.

Unlike RAVEL, RESHAPE can divide the series into columns of varying lengths.