To keep the table dimensions the same, try changing the columns to factors...
boxes$y97<-factor(boxes$y97, 1:4) boxes$y98<-factor(boxes$y98, 1:4) boxes$y99<-factor(boxes$y99, 1:4) ... > table(boxes$y98, boxes$y97) 1 2 3 4 1 1 0 1 0 2 0 0 0 0 3 0 0 0 0 4 1 0 0 1 > table(boxes$y99, boxes$y98) 1 2 3 4 1 1 0 0 1 2 0 0 0 0 3 0 0 0 0 4 1 0 0 1 Chris Abby_UNR wrote: > > My problem is that there are 16 possible transitions, but not all possible > transitions occur at each time step. Therefore, don't think I could do > something easy like create a table for each time step and add them > together, for example: > >> t1.boxes <- table(boxes$y98, boxes$y97) >> t1.boxes > > 1 3 4 > 1 1 1 0 > 4 1 0 1 >> t2.boxes <- table(boxes$y99, boxes$y98) >> t2.boxes > > 1 4 > 1 1 1 > 4 1 1 >> > > -- View this message in context: http://r.789695.n4.nabble.com/Markov-transition-matrices-missing-transitions-for-certain-years-tp3459072p3460651.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.