Well, this can help a lot. :) I have asked ChatGPT to provide me with an R code for the three-state Markov chain. He produces this in a few seconds, and the code is working. :) Even describe every line.