KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I wish to share an R function for finding all possible unique undirected combinations between elements of a single vector: combi <- function(vec1) { si <- length(vec1) first <- rep(vec1, (si-1):0) secR <- rev(vec1) second <- secR[sequence(1:(si-1))] second <- rev(second) combi <- matrix(cbind(first, second), ncol = 2) return(combi) } and ask if there is a simpler way of doing this? (I need the result to be in a 2-column matrix).
Tags (comma-separated)
Save Edits
Cancel