hsGroupBy2Fields: Two-field Grouping of a Data Frame

View source: R/hsLibBase.R

hsGroupBy2FieldsR Documentation

Two-field Grouping of a Data Frame

Description

Groups data by values in two columns creating a matrix with as many rows as there are distinct values in field1 and as many columns as there are distinct values in field2. The matrix contains the sum of values in the specified value field that belong to the corresponding value combination of field1/field2

Usage

hsGroupBy2Fields(
  frmData,
  strValField,
  strField1,
  strField2,
  boolDesc1 = FALSE,
  boolDesc2 = FALSE
)

Arguments

frmData

data.frame containing data to be grouped.

strValField

name of value field (= column in frmData)

strField1

name of first field to be grouped by

strField2

name of second field to be grouped by

boolDesc1

if TRUE, columns in result matrix will be ordered according to decreasing values of field1

boolDesc2

if TRUE, rows in result matrix will be ordered according to decreasing values of field2#'

Value

matrix with as many rows as there are distinct values in field1 and as many columns as there are distinct values in field2 of the input data.frame. The matrix contains the sum of values in the specified value field of the input data.frame that belong to the corresponding combination of values in field1/field2


KWB-R/kwb.base documentation built on June 19, 2022, 3:30 a.m.