I would like to automatically generate a Markov chain analysis for my set of bird songs that I have assigned syllable categories to using R. I have around 70 songs (each from an individual bird) and around 50 syllable categories, so calculating these transition probabilities by hand would be impossible. My sequences vary in length, with around 10-20 syllables in each song. I've assigned syllable categories to each song, for example, one sequence is "1, 1, 1, 36, 1, 1, 30, 30, 16, 31, 37, 37, 23, 17".
I need to create a script in R which would take a csv file of my sequences of different lengths, and count every transition between syllables (1-1, 1-2, 1-3, etc.) for every song. Then I need to calculate the frequency each transition occurs: ex. probability (1-1) = (number of times 1-1 occurs in a group of songs)/ (total number of times a transition begins with 1) .