bind.fill {irtQ} | R Documentation |
Bind Fill
Description
This function creates a matrix using either row-wise (rbind
) or column-wise
(cbind
) binding of a list of numeric vectors with varying lengths. Shorter
vectors are padded with a specified fill value.
Usage
bind.fill(List, type = c("rbind", "cbind"), fill = NA)
Arguments
List |
A list containing numeric vectors of possibly different lengths. |
type |
A character string indicating the type of binding to perform.
Options are |
fill |
A value used to fill missing elements when aligning the vectors.
For |
Value
A matrix formed by binding the elements of the list either row-wise
or column-wise, with shorter vectors padded by the specified fill
value.
Author(s)
Hwanggyu Lim hglim83@gmail.com
Examples
# Sample list
score_list <- list(item1 = 0:3, item2 = 0:2, item3 = 0:5, item4 = 0:4)
# 1) Create a row-bound matrix (rbind)
bind.fill(score_list, type = "rbind")
# 2) Create a column-bound matrix (cbind)
bind.fill(score_list, type = "cbind")
# 3) Create a column-bound matrix and fill missing values with 0
bind.fill(score_list, type = "cbind", fill = 0L)