Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>If you use dcast from the reshape2 package, you'll get a matrix that you can then do a pairwise correlation function on:</p> <pre><code>data &lt;- read.table(h=T, text="Order.ID Product + 193505 'Pineapple Cheddar Burger' + 193505 'Onion Rings' + 193564 'Pineapple Cheddar Burger' + 193623 'Hamburger' + 193623 'French Fries' + 193623 'Fountain Soda' + 193623 'Hot Dog' + 193631 'Hamburger' + 193631 'French Fries' + 193631 'Milkshake' + 193644 'Daily Special' + 193726 'Hamburger' + 193726 'French Fries' + 193726 'Fountain Soda' + 193728 'Hamburger' + 193728 'French Fries' + 193728 'Fountain Soda' + 193738 'Hamburger' + 193738 'French Fries' + 193762 'Hamburger' + 193762 'French Fries' + 193762 'Fountain Soda' + 193762 'Hamburger' + 193762 'French Fries' + 193762 'Fountain Soda'") library(reshape2) df &lt;- dcast(data, Order.ID ~ Product) cor(df[,-1], use = "pairwise") Daily Special Fountain Soda French Fries Hamburger Hot Dog Daily Special 1.0000 -0.2868 -0.4375 -0.4375 -0.1250 Fountain Soda -0.2868 1.0000 0.8030 0.8030 0.2294 French Fries -0.4375 0.8030 1.0000 1.0000 0.1250 Hamburger -0.4375 0.8030 1.0000 1.0000 0.1250 Hot Dog -0.1250 0.2294 0.1250 0.1250 1.0000 Milkshake -0.1250 -0.2868 0.1250 0.1250 -0.1250 Onion Rings -0.1250 -0.2868 -0.4375 -0.4375 -0.1250 Pineapple Cheddar Burger -0.1890 -0.4336 -0.6614 -0.6614 -0.1890 Milkshake Onion Rings Pineapple Cheddar Burger Daily Special -0.1250 -0.1250 -0.1890 Fountain Soda -0.2868 -0.2868 -0.4336 French Fries 0.1250 -0.4375 -0.6614 Hamburger 0.1250 -0.4375 -0.6614 Hot Dog -0.1250 -0.1250 -0.1890 Milkshake 1.0000 -0.1250 -0.1890 Onion Rings -0.1250 1.0000 0.6614 Pineapple Cheddar Burger -0.1890 0.6614 1.0000 </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload