问题 `function(trans,initprob,N)' { BrokerPosition <- c("BP", "IP", "SP") mysequence <- character() firstposition <- sample(BrokerPosition, 1, rep=TRUE, prob=initprob) mysequence[1] <- firstposition for (i in 2:N) { prevposition <- mysequence[i-1] probabilities <- trans[prevposition,] BPosition <- sample(BrokerPosition, 1, rep=TRUE, prob=probabilities) mysequence[i] <- BPosition } return(mysequence) } This is a function made to simulate Markov chain , but whenever I run it I get the error no