r_prodm(C;S)

Returns the element-wise product (Hadamard product) of matrix values across a given set of columns. (Available as of prod-9)

Function type

Vector only

Syntax

r_prodm(C;S)

Input

Argument Type Description
C matrix model A space- or comma-separated list of column names

C may also be a string expression (in single quotes) constituting a pattern for matching columns. For instance, 'foo*' specifies all columns that begin with "foo".

If C is omitted, the values in all of the columns are included.

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

S integer A boolean column or an expression in rcv_/rcn_/rct_ which determines whether or not that column is selected to be included in the calculation. See System variables for more information about rcv_/rcn_/rct_.

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

Return Value

For each row of the table, r_prodm returns a matrix model consisting of the element-wise product (Hadamard product) of all of the matrices in the columns specified by C.

If the columns specified by C do not have the same dimensions, an error is returned.

If any of the columns specified by C contain 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="r_prodm example">
John,8,0,5,1;
John,2,0,1,1;
Mary,3,1,2,2;
Mary,4,1,2,2
</table>
<willbe name="matrix_0_1_2" value="g_matrix(name;;;data_1 data_2;0)"/>
<willbe name="matrix_0_3_4" value="g_matrix(name;;;data_3 data_4;0)"/>
<willbe name="matrix_1_1_2" value="g_matrix(name;;;data_1 data_2;1)"/>
<willbe name="matrix_1_3_4" value="g_matrix(name;;;data_3 data_4;1)"/>
<willbe name="r_prodm_1_2" value="r_prodm(matrix_0_1_2 matrix_1_1_2;)"/>
<willbe name="r_prodm_3_4" value="r_prodm(matrix_0_3_4 matrix_1_3_4;)"/>
<willbe name="r_prodm_all" value="r_prodm('matrix*';)"/>

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

Clicking on the > character in the first row of the matrix_1_1_2 column displays the matrix model for those rows where name is John.

Clicking on the > character in the first row of the r_prodm_1_2 column displays the element-wise product of the matrices in columns matrix_0_1_2 and matrix_1_1_2for those rows where name is John.

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

Clicking on the > character in the first row of the matrix_1_3_4 column displays the matrix model for those rows where name is John.

Clicking on the > character in the first row of the r_prodm_3_4 column displays the element-wise product of the matrices in columns matrix_0_3_4 and matrix_1_3_4for those rows where name is John.

Finally, clicking on the > character in the first row of the r_prodm_all column displays the element-wise product of all columns whose names begin with "matrix" (i.e., matrix_0_1_2, matrix_0_3_4, matrix_1_1_2, matrix_1_3_4) for those rows where name is John.