Skip to content
Prev 12238 / 398502 Next

transitions in R

For the one-deep try
plength <- length(process)
table(process[1:(plength-1)],process[2:plength])

To get proportions,
table(process[1:(plength-1)],process[2:plength])/(plength-1)

Multiply by 100 to get percent, and use round() if needed.

I think you can extend this to more depth and get bigger tables.

Jon Baron
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._