I have a data frrame looking like this
My goal is to find the most common pair of items, in this case (1 and 3)
I already tried this:
names(tail(sort(table(unlist(tapply(ol$ORDER_ID, ol$SKU_ID,
FUN = function(x) if(length(x) > 1) combn(unique(x), 2, paste, collapse="-") else NA)))),
3))
But I keep getting this error message, and I don't know how to fix it.
Error in combn(unique(x), 2, paste, collapse = "-") : n < m
Someone suggested
library(dplyr), then count(your_data, ORDER_ID, SKU_ID) %>% arrange(desc(n))
But it still gives me the same error message, another person refered me to this post, but I struggle to see the relevance.