Viterbi algorithm for Hidden Markov Models in R