Answer to: Counting instances of genotype strings where order is irrelevant within locus
Score: 2
As @Rui Barradas mentioned, you could first make the sequence sorted and then apply table.
My solution follows the same idea but use order + intToUtf8 + utf8ToInt to finish the sorting processes
x <-c("AB", "Ab", "aB", "ab")
y <-c("AB", "Ab", "aB", "ab")
table(outer(x,y, Vectorize(\(p,q) {u <- paste0(p,q); intToUtf8(utf8ToInt(u)[order(utf8ToInt(u))])})))
and you will obtain
aabb Aabb AAbb AABb AABB ABab ABBa Baab BBaa
1 2 1 2 1 4 2 2 1
View Question ↗
Question
Parent Entity
Score: 4 • Views: 101
Site: stackoverflow
SaaS Metrics