I would like your experise on this example. I need to have all combinations of two vectors and remove if they are same and remove one copy if they are duplicated.
v1 <- c("AS", "KS", "AZ", "AL", "MO")
v2 <- c("AZ", "KZ", "LM", "AZ", "ZK")
I woule like to get combinations of v1 / v2 and I don't want reciprocal V2 / V1, so I use
z<-outer(v1,v2, paste, sep="/")
which gives me
[,1] [,2] [,3] [,4] [,5]
[1,] "AS/AZ" "AS/KZ" "AS/LM" "AS/AZ" "AS/ZK"
[2,] "KS/AZ" "KS/KZ" "KS/LM" "KS/AZ" "KS/ZK"
[3,] "AZ/AZ" "AZ/KZ" "AZ/LM" "AZ/AZ" "AZ/ZK"
[4,] "AL/AZ" "AL/KZ" "AL/LM" "AL/AZ" "AL/ZK"
[5,] "MO/AZ" "MO/KZ" "MO/LM" "MO/AZ" "MO/ZK"
But I need to modify to fit it in my analysis
Step 1. Remove same combination. I don't need to have the combinations which has same. In the above example there are two times AZ/AZ and both should be removed.
Step 2. Remove duplicated combinations. I don't need duplications. In the above example AL/AZ, AS/AZ, KS/AZ, MO/AZ are duplicated. One copy should be removed.
Step 3. Remove receprocal combinations if any. For instance AZ/AS is the same as AS/AZ.
Step 3. Sort all and keep them in single column.
"AL/AZ"
"AL/KZ"
"AL/LM"
"AL/ZK"
"AS/AZ"
"AS/KZ"
"AS/LM"
"AS/ZK"
"AZ/KZ"
"AZ/LM"
"AZ/ZK"
"KS/AZ"
"KS/KZ"
"KS/LM"
"KS/ZK"
"MO/AZ"
"MO/KZ"
"MO/LM"
"MO/ZK"
Thanks