# Is there a stats tool for this analysis I run in excel?

I am trying to find a statistical or machine learning tool that replicates this analysis I am doing manually in excel.

Each row in my data set is a user.

User | sites visits | pages viewed | items added to cart | Purchased (1 or 0)


I set up a pivot table so Purchased is in the columns field. I have it set to % of row.

Purchased   Didn't Purchase         Total
80%              20%                100%


I then add all the other variables as filters in the Pivot Table.

I start by filtering out the people who didn't view 1 page and see how that impacts that % of people who purchased. I then filter out the people who didn't view 2 pages, etc. I then start filtering out other variables to see how the interactions work together.

I am looking for a combination of inputs that leads to an 80% purchase rate. So maybe it's 2 visits, 6 pageviews, and 2 add to carts.

Is there a tool that automates this type of analysis?

• (i) I believe you could do the whole thing in a handful of lines of R code (or indeed in any number of other programs), but I don't know if that's what you mean (in particular, one might fit a saturated model and then find the closest combination of factors to the required level); (ii) are you after all combinations near 80%, or any single combination? (either could be done) Commented Jun 22, 2014 at 22:28
• Is the 80% prespecified, or are you trying to find a combination which matches the aggregate (essentially a kind of average value)? Commented Jun 22, 2014 at 22:52

While I don't think you need to produce a pivot table to do any part of that, the equivalent of pivot tables themselves can easily be done in vanilla R, or in several R packages. Two answers to this question shows how to do a pivot table in R via tapply (plain R) or with reshape2; I think several other functions in base R and in popular R packages have the same functionality (e.g. see here, or here and here and here. Searches in StackOverflow or in google provide many more examples.