View source: R/make_random_block.R
| make_random_block | R Documentation |
Generates a matrix of randomly paired blocks, where each row represents a block of items. This serves as a fast, unstructured initial solution for forced-choice test assembly algorithms.
make_random_block(total_items, target_items = total_items, block_size)
total_items |
Integer. The total number of items available in the item pool. |
target_items |
Integer. The number of items to sample from |
block_size |
Integer. The number of items in each block (e.g., 2 for pairs,
3 for triplets). Must be |
Given the total number of items in the pool, this function randomly samples
target_items and formats them into a block matrix.
If target_items is not a multiple of block_size, the function will
randomly draw additional items from the sampled pool to fill the incomplete final block,
ensuring the matrix structure is strictly maintained.
A matrix of integers indicating the item IDs. The number of rows equals
ceiling(target_items / block_size), and the number of columns
equals block_size.
# Use all 60 items to build 20 blocks of 3
make_random_block(total_items = 60, block_size = 3)
# Sample 45 items from a pool of 60 to build 15 blocks of 3
make_random_block(total_items = 60, target_items = 45, block_size = 3)
# Handle cases where target_items is not a multiple of block_size
# (Will randomly reuse 1 item to fill the last triplet)
make_random_block(total_items = 60, target_items = 50, block_size = 3)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.