g_summ(G;S;X)

Returns the element-wise sum of matrix values within a given group. (Available as of prod-9)

Function type

Vector only

Syntax

g_summ(G;S;X)

Input

Argument Type Description
G any A space- or comma-separated list of column names

Rows are in the same group if their values for all of the columns listed in G are the same.

If G is omitted, all rows are considered to be in the same group.

If any of the columns listed in G contain N/A, the N/A value is considered a valid grouping value.

S integer The name of a column in which every row evaluates to a 1 or 0, which determines whether or not that row is selected to be included in the calculation

If S is omitted, all rows will be considered by the function (subject to any prior row selections).

If any of the values in S are neither 1 nor 0, an error is returned.

X matrix model A column name

The column specified by this parameter must contain matrix models generated by the 1010data Matrix Functions.

Return Value

For every row in each group defined by G (and for those rows where S=1, if specified), g_summ returns a matrix model consisting of the element-wise sum of all of the matrices within the given group.

If X contains any N/A or scalar values, an error is returned.

Example

Consider the following example:

<table cols="name, data_1, data_2, data_3, data_4" title="g_summ example">
John,8,0,5,1;
John,2,0,1,1;
Mary,3,1,2,2;
Mary,4,1,2,2;
John,5,2,3,1
</table>
<willbe name="matrix_0" value="g_matrix(name;;;data_1 data_2 data_3 data_4;0)"/>
<willbe name="matrix_1" value="g_matrix(name;;;data_1 data_2 data_3 data_4;1)"/>
<willbe name="mat0_summ" value="g_summ(name;;matrix_0)"/>
<willbe name="mat1_summ" value="g_summ(name;;matrix_1)"/>

For every row, the matrix in mat0_summ will be the element-wise matrix addition of the matrices in matrix_0 for a particular group.

For example, clicking on the > character in the first row of the matrix_0 column displays the matrix model for those rows where name is John.

Clicking on the > character in the first row of the mat0_summ column displays the matrix model consisting of the element-wise matrix addition of the matrices in matrix_0 for those rows where name is John.

Clicking on the > character in the first row of the matrix_1 column displays the transpose of the matrix in the matrix_0 column.

Finally, clicking on the > character in the first row of the mat1_summ column displays the matrix model consisting of the element-wise matrix addition of the matrices in matrix_1 for those rows where name is John.