MATRIX

Section: User Commands (1)
Updated: 1. April 1989
 

NAME

matrix - transform (z,x,y)-style data to matrix format.  

SYNOPSIS

matrix -f format [ < data ]  

DESCRIPTION

matrix reads a three-column table (as written by count(1)) from the standard input and transforms it to matrix format by summing the first column into a matrix indexed by the second and third column.

The format option should be used to obtain pretty output. It refers to the format of all columns after the first one.

The z-columns (typically frequencies) can be any real numbers. The coordinate columns can be arbitrary positive integers, although matrix does put limits on their size.

This is best explained by way of an example. Suppose the file data contains the lines:

count   x       y 
-----   -       -
1       1       2
1       1       3
2       3       4
2       4       5
2       4       6
where exactly one tab-character separates the columns.

The command matrix "\t%.0f" < data yields

y       x1      x2      x3      x4
-       --      --      --      --
2       1       0       0       0
3       1       0       0       0
4       0       0       2       0
5       0       0       0       2
6       0       0       0       2
on the standard output.

The input does not need to be sorted in any way.  

SEE ALSO

reldb(1), count(1).  

BUGS

Matrix has hardwired dimensions. This should definitely be changed.

Other options may be available, e.g. to control whether lines consisting of all zeros are output. Check the code.