Build a path probability tree for journeys through a website I'm currently doing analysis on a website which requires that I create a decision tree diagram showing the likely route that people take whenever they arrive on the website. I am dealing with a data.frame which shows the paths of all customers to the site, starting from the homepage.
For example, a customer could take the following path:
Homepage - pg 1
Kitchen Items page - pg 2
Pots and Pans page - pg 3

so this customer would have a 3 page journey. What I want to try to do in R is combine all customers paths and thereby assign a probability to a customer following a certain path on the site. For example, if I were to examine all paths I could find that 34% of people who arrive on the Homepage go onto the 'Kitchen items page'.  Does R have this facility?
I have looked up different methods through the rpart and partykit packages but they didn't seem to be of any help. 
Any steer in the right direction for this is very much appreciated!
 A: Isn't one way to start, is to have a $n \times n$ matrix (say $M_{n \times n}$) where $n$ is the number of pages. Then based on your raw data increment matrix element $M_{rc}$ by one whenever you have a user hop from page $r$ to page $c$. That gets you the transition probabilities. 
Your first question is already answered by this: "What percent of users on homepage (say page 1) travel next to, say, Kitchen Items (say page 2)?"
$\frac{M_{12}}{ \sum_c M_{1c}}$
Or is this too simplistic? 
A: It looks like you are trying to recreate the PageRank algorithm of Google.  Most of the PageRank algorithm was developed using Markov Chains.  You can find a lot of mentions of developing PageRank methods in R.
igraph.sourceforge.net/doc/R/page.rank.htm
A: From what I see here, I agree that igraphs / Markov Chains is probably the way to go, however you could definitely use rpart and/or the partykit.
It's hard for me to give a simple answer with your limited example, but I can explain generally how you would do it. 
You want look at where all your users had been, and summarize that into a string for example 
"Home / product4 / product3 / product4 / buynow"
"Home / product3 / buynow"
"Home / product3 / product4"

You could then segment your users into categories, say ones who ended up in the "buy now" page, and ones who didn't.  Then you could simply start predicting on that terminal result.  In this example, maybe you would find out that people who did the most comparison shop did / didn't buy something.
You could also make more variables, like "what was the page before the buynow page" "how many pages did they visit before buying something" or "when did they create their first account", and you could add those metrics to your analysis.  
There are a lot of different ways you could go, and this begins to answer different questions, but my point is that you could use the trees and for some problems it might be a faster and simpler route to insight.
By the way, you would need to make non-numeric variables factors by using factor or as.factor, if you're going to use party.  Party has some nice vignettes to get you started.
