headerRuns: Runs of Repeated Values in a Header Matrix

Description Usage Arguments Details Value

View source: R/headerRuns.bare.R

Description

Identify runs of repeated values in a matrix of row or columns headers. Detection of runs respects the hierarchical structure of headers. This is an internal utility function, not intended to be called by package users.

Usage

1
headerRuns(x, which_head)

Arguments

x

A matrix containing table row or column headers.

which_head

Character scalar, "row" or "col", indicating whether x contains row headers or column headers. "row" means that each column corresponds to one header variable or layer, ordered from outermost to innermost, left to right (i.e., as the header would be displayed). "col" means that each _row_ corresponds to one header variable, ordered from outermost (top) to innermost (bottom), again as the header would be displayed.

Details

Runs are defined cumulatively across header variables. For the outermost variable, runs consist of consecutive duplicated values in the first column/row of x; for the second-outermost variable, runs are defined by consecutive duplicated values in the first two columns/rows of x, and so on. (That is, the header variables are treated as a hierarchy, with inner variables nested within outer ones.)

Value

A list with one component per header variable in x. Each component is a data frame. The i-th data frame has one row per run of values in the i-th header variable, with columns:

headlayer

Header layer number, increasing from innermost (most deeply nested) to outermost. Thus for "row" headers it is the reverse of column number in x (ncol(x) - i + 1), and for "col" headers it is the reverse of row number in x (nrow(x) - i + 1).

level_in_layer

Run number within the layer. Levels are numbered from 1, so this column is just the sequence from 1 to the number of rows in the data frame.

value

The value in x associated with the run.

start

Position in x where the run starts (row number for "row" headers, column number for "col" headers).

runlen

Length of the run (number of rows or columns).

If x is NULL, the returned value is also NULL. If x has no header variables, the returned value is an empty list, list().


tablesgg documentation built on June 3, 2021, 1:06 a.m.