How to sum the number of occurrences at each position in the fragment?
On the abscissa there are the possible letters.
On the ordinate there are the positions (position 1, position 2, ..., position 8).
In the table we have the occurrence of each letter in the 8 positions.
For fragment 1 I will have: TATLQAKA: 5 + 2 + 3 + 4 + 2 + 1 + 1 + 4 = 22
(T was found 5 times in position 1 + A which was found 2 times in position 2 + T which was found 3 times)
data.frame(Segments = c("TATLQAKA", "QCLKMLET", "EARKIFRF", "SKKELKEL", "CPVGFLGN", "VNTQPGFH", "GDGRGDIC", "IPSNFVSP", "EFFRGLNI", "SCTYQLAR"),
stringsAsFactors = FALSE)
by a segment list contained in a file like "segment.txt",
Think you
Then, read that file in R using read.csv and use the rest of the code.
By the way, I found that strsplit can be used in this instead of stringr::str_split_fixed. Hence, being biased, let me post that solution too (essentially they are same).