union#

Purpose#

Returns the union of two vectors with duplicates removed.

Format#

y = union(v1, v2, flag)#
Parameters:
  • v1 (Nx1 vector) – data

  • v2 (Mx1 vector) – data

  • flag (scalar) – 1 if numeric data, 0 if character.

Returns:

y (Lx1 vector) – contains all unique values that are in v1 and v2, sorted in ascending order.

Examples#

// Create two column vectors with character data

v1 = { mary, jane, linda, john };
v2 = { mary, sally };

x = union(v1, v2, 0);

// The '$' in front of 'x' tells GAUSS to print 'x' as
// character data
print $x;

The above code will produce the following results:

JANE
 JOHN
LINDA
 MARY
SALLY

Remarks#

The combined elements of v1 and v2 must fit into a single vector.