Problem description
I have a list of strings of equal size like this:
example.list <- c('BBCD','ABBC','ADDB','ACBB')
Then I want to obtain the frequency of occurence of specific letters at specific positions. First I convert this to a matrix:
A1 B1 C1 D1 A2 B2 C2 D2 A3 B3 C3 D3 A4 B4 C4 D4
[1,] 0 1 0 0 0 1 0 0 0 0 1 0 0 0 0 1
[2,] 1 0 0 0 0 1 0 0 0 1 0 0 0 0 1 0
[3,] 1 0 0 0 0 0 0 1 0 0 0 1 0 1 0 0
[4,] 1 0 0 0 0 0 1 0 0 1 0 0 0 1 0 0
[5,] 1 0 0 0 0 1 0 0 0 1 0 0 0 0 0 1
Now I want to obtain the frequency of each column combination. Some examples:
A1 : B2 = 2
A1 : B3 = 3
B1 : B2 = 1
.. etc