REPLACE

Purpose:

Replaces values in a series based on a logical condition.

Syntax:

REPLACE(series, condition, newval)

series

-

A series, the input to replace from.

condition

-

A binary series or logical expression resulting in a binary series. The replacement condition.

newval

-

A real, the replacement value.

Returns:

A series, or table.

Example:

W1: 1..5

W2: replace(W1, W1 > 3, -1)

 

W2 contains the series {1, 2, 3, -1, -1}. Any value in W1 that is greater than 3 is replaced with the value -1.

Example:

W1: gnorm(1000,1)

W2: gnorm(1000,1)

W3: replace(W1, W2 > W1, W2)

 

The series in W3 contains the point by point maximums of W1 and W2. This is equivalent to max(W1, W2).

Remarks:

REPLACE uses a binary series to detect and replace values. The existing value is preserved where condition == 0 and the value is replaced by newval where condition != 0.

 

See OUTLIER to replace outlier values with a linear interpolation of the surrounding values.

See Also:

DELETE

DELETECOL

DELETEROW

DELMATCH

DECIMATE

INSERT

INSERTCOL

OUTLIER

REMOVE

REPLACECOL

SETNAVALUE

VALFILL