sparse_mat | R Documentation |
This functions returns a binary matrix
sparse_mat(vlist, vorder)
vlist |
The vlist a list consists from character, integer or binary vectors. |
vorder |
logical: If 'vlist' consists of an ordered vector or not. The default value is FALSE. |
a data frame of sparse matrix which first column unique elements of a list
set.seed(1) int_list <- lapply(1:6, function(i) abs(as.integer(rnorm(6, mean = i)))) bin_list <- lapply(1:6, function(i) round(runif(4, 0, 1))) chr_list <- lapply(1:6, function(i) sample(letters, size = 4)) ochr_list <- lapply(1:6, function(i) setNames(sample(c('A','B','C'), 4, replace =TRUE), 1:4)) ochr_dat <- data.frame(ochr_list, stringsAsFactors = FALSE) sparse_mat(int_list); sparse_mat(bin_list); sparse_mat(chr_list); sparse_mat(ochr_list, vorder =TRUE) sparse_mat(ochr_dat, vorder =TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.