quickblock (version 0.2.0)

qb_blocking: Constructor for qb_blocking objects

Description

The qb_blocking function constructs a qb_blocking object from existing block labels. The function does not derive blockings from sets of data points; see quickblock for that functionality.

Usage

qb_blocking(block_labels, unassigned_labels = NULL, ids = NULL)

Value

Returns a qb_blocking object with the blocking described by the provided labels.

Arguments

block_labels

a vector containing each unit's block label.

unassigned_labels

labels that denote unassigned units. If NULL, NA values in block_labels are used to denote unassigned units.

ids

IDs of the units. Should be a vector of the same length as block_labels or NULL. If NULL, the IDs are set to 1:length(group_labels).

Details

qb_blocking objects are based on integer vectors, and it indexes the blocks starting with zero. The qb_blocking class inherits from the scclust class.

Examples

Run this code
# 10 units in 3 blocks
blocking1 <- qb_blocking(c("A", "A", "B", "C", "B",
                           "C", "C", "A", "B", "B"))

# 8 units in 3 blocks, 2 units unassigned
blocking2 <- qb_blocking(c(1, 1, 2, 3, 2,
                           NA, 3, 1, NA, 2))

# Custom labels indicating unassigned units
blocking3 <- qb_blocking(c("A", "A", "B", "C", "NONE",
                           "C", "C", "NONE", "B", "B"),
                        unassigned_labels = "NONE")

# Two different labels indicating unassigned units
blocking4 <- qb_blocking(c("A", "A", "B", "C", "NONE",
                           "C", "C", "0", "B", "B"),
                        unassigned_labels = c("NONE", "0"))

# Custom unit IDs
blocking5 <- qb_blocking(c("A", "A", "B", "C", "B",
                           "C", "C", "A", "B", "B"),
                        ids = letters[1:10])

Run the code above in your browser using DataCamp Workspace