added R script for second order markov chains