P=matrix(c(0.6,0.2,0.2,0.4,0.3,0.3,.2,.2,.6),nrow=3,byrow=T)

n=100000

x=numeric(n)

pi0=c(0.5,0.2,0.3)

state=sample(1:3,1,prob=pi0)

x[1]=state

x[1]

for (i in 2:n) {

state=sample(1:3,1,prob=P[state,])

x[i]=state

}

table(x)

Can you explain how to find table(x)??