Relational tables and multiD arrays

Revision as of 00:17, 12 December 2015 by Bbecane (talk | contribs)

The MDArrayToTable() function “flattens” a multi-dimensional array into a two-dimensional relational table. When a simple relational transformation is desired, the table will have one row for each array element and only one column (the right-most column) containing those element values. Alternatively MDArrayToTable() can produce a fact table in which values occupy multiple columns divided over a specified index, referred to as the Value Index. Both of these methods are described in separate sections below. The third section applies to both kinds of tables and describes partial transformations in which the MDArrayToTable() function will only operate on a subset of indexes, leaving the rest in array form.

The MDTable() function does the inverse, creating a multi-dimensional array from a table of values. Viewing tabular results in a multi-dimensional form via MDTable() often provides informative new perspective on existing data.

Many external application programs, including spreadsheets and relational databases, are limited to two-dimensional tables. Thus, before transferring multi-dimensional data between these applications and Analytica, it might be necessary to convert between multi-dimensional arrays and two-dimensional tables.

MDArrayToTable(a, row, col) (pure relational transformation)

Transforms a multi-dimensional array, a, into a two-dimensional array (i.e., a table) indexed by row and col. The result contains one row along row for each element of a. Each column along col, except the far right column, represents a coordinate index from the array. Index columns are populated with the coordinate values for the element. The far right column contains the actual value of the element. Both row and col are optional, if either or both is omitted, a local index of the appropriate length is automatically created. The local index col contains handles to the array’s indexes for the coordinate columns.

If you provide the index row with the number of elements equal to size(a), the resulting table will contain all array elements. If the number of elements in row is equal to the number of nonempty elements of a, the resulting table will contain only the non-empty elements of the array. If the number of elements in row is anything else, an error will occur. The optional parameters omitNull and omitZero control what is considered to be empty. When you omit row, the local index is sized for the non-empty elements, or you can obtain all elements by setting both omitNull and omitZero to false.

Library: Array

Example: Starting with “Array_3x3x3” indexed by “Number”, “Letter”, and “Hue”




See Also

Comments


You are not allowed to post comments.