Paste all combinations of a vector in R -


i have vector say:

vec = c("a", "b", "c") 

and want paste single combinations of every item in vector result

ab ac bc 

i know can use outer possible combinations of vector, stumped how result above. order doesn't matter in case, result plausibly be

ba ca cb 

i need combine single pairs.

sam

try combn

 combn(vec,2, fun=paste, collapse='')  #[1] "ab" "ac" "bc" 

Popular posts from this blog