| bind.fill | R Documentation |
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.
bind.fill(List, type = c("rbind", "cbind"), fill = NA)
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 |
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.
Hwanggyu Lim hglim83@gmail.com
# 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.