if (requireNamespace("ggplot2", quietly = TRUE)) {
weather <- matrix(c(0.7, 0.2, 0.1,
0.3, 0.4, 0.3,
0.2, 0.45, 0.35),
nrow = 3, byrow = TRUE,
dimnames = list(c("sunny", "cloudy", "rain"),
c("sunny", "cloudy", "rain")))
mc <- new("markovchain", states = rownames(weather),
transitionMatrix = weather, name = "Weather")
ggplot2::autoplot(mc)
}
Run the code above in your browser using DataLab