Paste all combinations of a vector in R
I have a vector say: vec = c("A", "B", "C") And I want to paste single combinations of every item in the vector to get the result AB AC BC I know I can use outer to get all possible combinations of the vector, but I am stumped as how to only get the result above. Order doesn't matter in this case, so the result could plausibly also be BA CA CB I just need to combine the single pairs. Sam Try combn combn(vec,2, FUN=paste, collapse='') #[1] "AB" "AC" "BC" 来源: https://stackoverflow.com/questions/29549562/paste-all-combinations-of-a-vector-in-r