Thank you in advance for any help with this issue.
I am currently conducting an analysis where we are looking at pairwise differences between insect groups. However I have run into a frustrating issue that I can't seem to fix without hundreds of lines of code.
For example, we have pairwise comparisons as characters, which were constructed from two columns group1
and group2
using paste
but this results in mirrored groups i.e. A_B
and B_A
.
Does anyone know a solution so we can make these both bee_beetle
? Or rather a different function to make our pairwise groups.
Here is a quick example...
df=cbind.data.frame(c("A","B","C","D"),c("B","A","D","C"))
colnames(df)=c("Group1","Group2")
paste(df$Group1,df$Group2,sep="_")
"A_B" "B_A" "C_D" "D_C"
But I would like "A_B","A_B","C_D","C_D"
irrespective of which group (1 or 2)
We have about 400 odd groupings that we need to normalise.
Thanks again
Liam