InsertVerticalPanels: Expand a 3D array on the second dimension, inserting empty...

View source: R/InsertVerticalPanels.R

InsertVerticalPanelsR Documentation

Expand a 3D array on the second dimension, inserting empty layers where the input vector has a 0 value. A 2D argument x with dim(x)==c(r,c) is first extended to 3D with dim(x)==c(1,r,c), and then the result is collapsed back to 2D.

Description

Expand a 3D array on the second dimension, inserting empty layers where the input vector has a 0 value. A 2D argument x with dim(x)==c(r,c) is first extended to 3D with dim(x)==c(1,r,c), and then the result is collapsed back to 2D.

Usage

InsertVerticalPanels(x, expansion, newRowheights=5, newValue=NA)

Arguments

x

Three-dimensional array, for example, one defined as a set of matrices for the likert and related functions. x[1,,] and more generally x[i,,] will be an argument to likert.

expansion

Vector of 0 and 1, with 1 indicating an existing layer in dimension 2, and 0 a placeholder for where a new layer in dimension 2 should be inserted.

newRowheights

Value to be used for inserted row by likertWeighted function.

newValue

Value to be inserted in all positions of inserted layer.

Value

Array similarly structured to the input array x, but with more layers on the second dimension. The "rowheights" attribute gives the rowheights used by EmphasizeVerticalPanels. The newRows gives the row (second dimension) numbers in the result that are the generated values. All data items in the newRows will have value in the newValue argument.

Author(s)

Richard M. Heiberger <rmh@temple.edu>

See Also

EmphasizeVerticalPanels

Examples


x <- array(1:24, c(3, 4, 2),
                dimnames = list(letters[1:3], LETTERS[4:7], letters[8:9]))
x

expansion <- c(1, 1, 0, 1, 0, 1)
result <- InsertVerticalPanels(x, expansion)
result

Pop.labels1 <- result[1,, ]
Pop.labels1[ attr(result, "newRows"),] <- " "

Pop.labels2 <- result[2,, ]
Pop.labels2[ attr(result, "newRows"),] <- " "

Pct.labels1 <- format(round(HH::rowPcts(result[1,, ])))
Pct.labels1[ attr(result, "newRows"),] <- " "

Pct.labels2 <- format(round(HH::rowPcts(result[2,, ])))
Pct.labels2[ attr(result, "newRows"),] <- " "


HH documentation built on May 29, 2024, 6:24 a.m.

Related to InsertVerticalPanels in HH...